quantproject-developers Mailing List for QuantProject (Page 34)
Brought to you by:
glauco_1
You can subscribe to this list here.
| 2003 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(7) |
Nov
(103) |
Dec
(67) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2004 |
Jan
(52) |
Feb
(9) |
Mar
(69) |
Apr
(53) |
May
(80) |
Jun
(23) |
Jul
(24) |
Aug
(112) |
Sep
(9) |
Oct
|
Nov
(58) |
Dec
(93) |
| 2005 |
Jan
(90) |
Feb
(93) |
Mar
(61) |
Apr
(56) |
May
(37) |
Jun
(61) |
Jul
(55) |
Aug
(68) |
Sep
(25) |
Oct
(46) |
Nov
(41) |
Dec
(37) |
| 2006 |
Jan
(33) |
Feb
(7) |
Mar
(19) |
Apr
(27) |
May
(73) |
Jun
(49) |
Jul
(83) |
Aug
(66) |
Sep
(45) |
Oct
(16) |
Nov
(15) |
Dec
(7) |
| 2007 |
Jan
(14) |
Feb
(33) |
Mar
|
Apr
(21) |
May
|
Jun
(34) |
Jul
(18) |
Aug
(100) |
Sep
(39) |
Oct
(55) |
Nov
(12) |
Dec
(2) |
| 2008 |
Jan
(120) |
Feb
(133) |
Mar
(129) |
Apr
(104) |
May
(42) |
Jun
(2) |
Jul
(52) |
Aug
(99) |
Sep
(134) |
Oct
|
Nov
(137) |
Dec
(48) |
| 2009 |
Jan
(48) |
Feb
(55) |
Mar
(61) |
Apr
(3) |
May
(2) |
Jun
(1) |
Jul
|
Aug
(51) |
Sep
|
Oct
(7) |
Nov
|
Dec
|
| 2010 |
Jan
(7) |
Feb
(1) |
Mar
(145) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(8) |
Dec
|
| 2011 |
Jan
(78) |
Feb
(1) |
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
(88) |
Sep
(6) |
Oct
(1) |
Nov
|
Dec
|
| 2012 |
Jan
|
Feb
(1) |
Mar
|
Apr
(6) |
May
(5) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(1) |
| 2013 |
Jan
|
Feb
|
Mar
|
Apr
(1) |
May
(2) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(2) |
| 2014 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(1) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
|
From: Glauco S. <gla...@us...> - 2008-09-29 21:18:30
|
Update of /cvsroot/quantproject/QuantProject/b4_Business/a2_Strategies In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv16256 Modified Files: WeightedPosition.cs WeightedPositions.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: WeightedPosition.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b4_Business/a2_Strategies/WeightedPosition.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** WeightedPosition.cs 14 Jan 2008 23:24:48 -0000 1.3 --- WeightedPosition.cs 29 Sep 2008 21:17:57 -0000 1.4 *************** *** 99,110 **** new HistoricalAdjustedQuoteProvider(); double todayMarketValueAtClose = ! historicalAdjustedQuoteProvider.GetMarketValue( ticker , ! new EndOfDayDateTime( dateTime , EndOfDaySpecificTime.MarketClose ) ); DateTime yesterday = dateTime.AddDays( -1 ); ! EndOfDayDateTime yesterdayAtClose = new ! EndOfDayDateTime( yesterday , EndOfDaySpecificTime.MarketClose ); double yesterdayMarketValueAtClose = historicalAdjustedQuoteProvider.GetMarketValue( ! ticker , yesterdayAtClose ); double dailyReturnForLongPosition = ( todayMarketValueAtClose / yesterdayMarketValueAtClose ) - 1; --- 99,112 ---- new HistoricalAdjustedQuoteProvider(); double todayMarketValueAtClose = ! historicalAdjustedQuoteProvider.GetMarketValue( ! ticker , HistoricalEndOfDayTimer.GetMarketClose( dateTime ) ); ! // new EndOfDayDateTime( dateTime , EndOfDaySpecificTime.MarketClose ) ); DateTime yesterday = dateTime.AddDays( -1 ); ! DateTime yesterdayAtClose = ! HistoricalEndOfDayTimer.GetMarketClose( yesterday ); ! // new EndOfDayDateTime( yesterday , EndOfDaySpecificTime.MarketClose ); double yesterdayMarketValueAtClose = historicalAdjustedQuoteProvider.GetMarketValue( ! ticker , yesterdayAtClose ); double dailyReturnForLongPosition = ( todayMarketValueAtClose / yesterdayMarketValueAtClose ) - 1; Index: WeightedPositions.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b4_Business/a2_Strategies/WeightedPositions.cs,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** WeightedPositions.cs 27 Feb 2008 22:17:10 -0000 1.14 --- WeightedPositions.cs 29 Sep 2008 21:17:57 -0000 1.15 *************** *** 256,261 **** HistoricalAdjustedQuoteProvider historicalAdjustedQuoteProvider = new HistoricalAdjustedQuoteProvider(); ! EndOfDayDateTime endOfDayDateTime = ! new EndOfDayDateTime( dateTime , EndOfDaySpecificTime.MarketClose ); foreach( WeightedPosition weightedPosition in this.Values ) { --- 256,261 ---- HistoricalAdjustedQuoteProvider historicalAdjustedQuoteProvider = new HistoricalAdjustedQuoteProvider(); ! // EndOfDayDateTime endOfDayDateTime = ! // new EndOfDayDateTime( dateTime , EndOfDaySpecificTime.MarketClose ); foreach( WeightedPosition weightedPosition in this.Values ) { *************** *** 265,269 **** double tickerQuote = historicalAdjustedQuoteProvider.GetMarketValue( ! ticker , endOfDayDateTime ); double virtualQuantityForThisPosition = valueForThisPosition / tickerQuote; if ( weightedPosition.IsShort ) --- 265,269 ---- double tickerQuote = historicalAdjustedQuoteProvider.GetMarketValue( ! ticker , dateTime ); double virtualQuantityForThisPosition = valueForThisPosition / tickerQuote; if ( weightedPosition.IsShort ) *************** *** 299,306 **** foreach( string ticker in tickerVirtualQuantities.Keys ) { ! EndOfDayDateTime endOfDayDateTime = new EndOfDayDateTime( ! dateTime , EndOfDaySpecificTime.MarketClose ); double tickerQuote = historicalAdjustedQuoteProvider.GetMarketValue( ! ticker , endOfDayDateTime ); double virtualQuantity = (double)tickerVirtualQuantities[ ticker ]; virtualPortfolioValue += virtualQuantity * tickerQuote; --- 299,306 ---- foreach( string ticker in tickerVirtualQuantities.Keys ) { ! // EndOfDayDateTime endOfDayDateTime = new EndOfDayDateTime( ! // dateTime , EndOfDaySpecificTime.MarketClose ); double tickerQuote = historicalAdjustedQuoteProvider.GetMarketValue( ! ticker , dateTime ); double virtualQuantity = (double)tickerVirtualQuantities[ ticker ]; virtualPortfolioValue += virtualQuantity * tickerQuote; |
|
From: Glauco S. <gla...@us...> - 2008-09-29 21:18:24
|
Update of /cvsroot/quantproject/QuantProject/b4_Business/a2_Strategies/EquityEvaluation In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv16256/EquityEvaluation Modified Files: WinningPeriods.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: WinningPeriods.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b4_Business/a2_Strategies/EquityEvaluation/WinningPeriods.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** WinningPeriods.cs 10 Feb 2008 15:26:34 -0000 1.3 --- WinningPeriods.cs 29 Sep 2008 21:17:57 -0000 1.4 *************** *** 29,32 **** --- 29,33 ---- /// periods on the total number of non flat periods /// </summary> + [Serializable] public class WinningPeriods : IEquityEvaluator { |
|
From: Glauco S. <gla...@us...> - 2008-09-29 21:18:15
|
Update of /cvsroot/quantproject/QuantProject/b4_Business/a2_Strategies/returnsManagement In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv16161/returnsManagement Modified Files: ReturnsManager.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: ReturnsManager.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b4_Business/a2_Strategies/returnsManagement/ReturnsManager.cs,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** ReturnsManager.cs 13 Nov 2007 19:10:28 -0000 1.9 --- ReturnsManager.cs 29 Sep 2008 21:17:39 -0000 1.10 *************** *** 39,46 **** /// by in sample optimizations) /// </summary> public class ReturnsManager { private ReturnIntervals returnIntervals; // a return for each interval ! private IHistoricalQuoteProvider historicalQuoteProvider; private Set tickersMissingQuotes; --- 39,47 ---- /// by in sample optimizations) /// </summary> + [Serializable] public class ReturnsManager { private ReturnIntervals returnIntervals; // a return for each interval ! private HistoricalMarketValueProvider historicalMarketValueProvider; private Set tickersMissingQuotes; *************** *** 78,87 **** /// n-1 elements</param> public ReturnsManager( ReturnIntervals returnIntervals , ! IHistoricalQuoteProvider historicalQuoteProvider ) { // TO DO: let WFLagEligibleTickers use this class also!!! this.returnIntervals = returnIntervals; this.commonInitialization(); ! this.historicalQuoteProvider = historicalQuoteProvider; } private void commonInitialization() --- 79,88 ---- /// n-1 elements</param> public ReturnsManager( ReturnIntervals returnIntervals , ! HistoricalMarketValueProvider historicalMarketValueProvider ) { // TO DO: let WFLagEligibleTickers use this class also!!! this.returnIntervals = returnIntervals; this.commonInitialization(); ! this.historicalMarketValueProvider = historicalMarketValueProvider; } private void commonInitialization() *************** *** 102,118 **** return this.tickersReturns.ContainsKey( ticker ); } #region setReturns private float selectReturnWithRespectToTheGivenIterval( ! EndOfDayHistory endOfDayQuotes , int i ) { ReturnInterval returnInterval = this.returnIntervals[ i ]; ! double firstQuote = (double)endOfDayQuotes[ returnInterval.Begin ]; ! double lastQuote = (double)endOfDayQuotes[ returnInterval.End ]; float intervalReturn = Convert.ToSingle( lastQuote / firstQuote - 1 ); return intervalReturn; } private float[] selectReturnsWithRespectToTheGivenIntervals( ! EndOfDayHistory endOfDayQuotes ) { // TO DO: this method is n log n, it could be implemented to --- 103,120 ---- return this.tickersReturns.ContainsKey( ticker ); } + #region setReturns private float selectReturnWithRespectToTheGivenIterval( ! History marketValues , int i ) { ReturnInterval returnInterval = this.returnIntervals[ i ]; ! double firstQuote = (double)marketValues[ returnInterval.Begin ]; ! double lastQuote = (double)marketValues[ returnInterval.End ]; float intervalReturn = Convert.ToSingle( lastQuote / firstQuote - 1 ); return intervalReturn; } private float[] selectReturnsWithRespectToTheGivenIntervals( ! History marketValues ) { // TO DO: this method is n log n, it could be implemented to *************** *** 122,141 **** for ( int i = 0 ; i < this.returnIntervals.Count ; i++ ) returnsWithRespectToTheGivenIntervals[ i ] = ! this.selectReturnWithRespectToTheGivenIterval( endOfDayQuotes , i ); return returnsWithRespectToTheGivenIntervals; } private void setReturnsActually( string ticker , ! EndOfDayHistory endOfDayQuotes ) { float[] arrayOfReturns = ! this.selectReturnsWithRespectToTheGivenIntervals( endOfDayQuotes ); this.tickersReturns.Add( ticker , arrayOfReturns ); } private void setReturns( string ticker , ! EndOfDayHistory endOfDayQuotes ) { if ( this.returnIntervals.AreIntervalBordersAllCoveredBy( ! endOfDayQuotes ) ) ! this.setReturnsActually( ticker , endOfDayQuotes ); else this.tickersMissingQuotes.Add( ticker ); --- 124,143 ---- for ( int i = 0 ; i < this.returnIntervals.Count ; i++ ) returnsWithRespectToTheGivenIntervals[ i ] = ! this.selectReturnWithRespectToTheGivenIterval( marketValues , i ); return returnsWithRespectToTheGivenIntervals; } private void setReturnsActually( string ticker , ! History marketValues ) { float[] arrayOfReturns = ! this.selectReturnsWithRespectToTheGivenIntervals( marketValues ); this.tickersReturns.Add( ticker , arrayOfReturns ); } private void setReturns( string ticker , ! History marketValues ) { if ( this.returnIntervals.AreIntervalBordersAllCoveredBy( ! marketValues ) ) ! this.setReturnsActually( ticker , marketValues ); else this.tickersMissingQuotes.Add( ticker ); *************** *** 143,152 **** private void setReturns( string ticker ) { ! EndOfDayHistory endOfDayQuotes = ! this.historicalQuoteProvider.GetEndOfDayQuotes( ticker , ! this.returnIntervals.BordersHistory ); ! this.setReturns( ticker , endOfDayQuotes ); } #endregion setReturns private float[] getAlreadySetReturns( string ticker ) { --- 145,156 ---- private void setReturns( string ticker ) { ! History marketValues = ! this.historicalMarketValueProvider.GetMarketValues( ! ticker , ! this.returnIntervals.BordersHistory ); ! this.setReturns( ticker , marketValues ); } #endregion setReturns + private float[] getAlreadySetReturns( string ticker ) { *************** *** 164,167 **** --- 168,172 ---- } #endregion GetReturns + #region GetReturn /// <summary> |
|
From: Glauco S. <gla...@us...> - 2008-09-29 21:18:11
|
Update of /cvsroot/quantproject/QuantProject/b4_Business/a2_Strategies In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv16161 Modified Files: SignedTicker.cs TradingSystem.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: TradingSystem.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b4_Business/a2_Strategies/TradingSystem.cs,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** TradingSystem.cs 13 Oct 2003 21:59:14 -0000 1.1.1.1 --- TradingSystem.cs 29 Sep 2008 21:17:40 -0000 1.2 *************** *** 64,68 **** } ! public abstract Signals GetSignals( ExtendedDateTime extendedDateTime ); public virtual void InitializeData() --- 64,68 ---- } ! public abstract Signals GetSignals( DateTime dateTime ); public virtual void InitializeData() Index: SignedTicker.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b4_Business/a2_Strategies/SignedTicker.cs,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** SignedTicker.cs 21 Aug 2007 22:06:35 -0000 1.10 --- SignedTicker.cs 29 Sep 2008 21:17:40 -0000 1.11 *************** *** 193,204 **** new HistoricalAdjustedQuoteProvider(); double todayMarketValueAtClose = ! historicalAdjustedQuoteProvider.GetMarketValue( ticker , ! new EndOfDayDateTime( today , EndOfDaySpecificTime.MarketClose ) ); DateTime yesterday = today.AddDays( -1 ); ! EndOfDayDateTime yesterdayAtClose = new ! EndOfDayDateTime( yesterday , EndOfDaySpecificTime.MarketClose ); double yesterdayMarketValueAtClose = historicalAdjustedQuoteProvider.GetMarketValue( ! ticker , yesterdayAtClose ); double dalyReturnForLongPosition = ( todayMarketValueAtClose / yesterdayMarketValueAtClose ) - 1; --- 193,204 ---- new HistoricalAdjustedQuoteProvider(); double todayMarketValueAtClose = ! historicalAdjustedQuoteProvider.GetMarketValue( ! ticker , HistoricalEndOfDayTimer.GetMarketClose( today ) ); DateTime yesterday = today.AddDays( -1 ); ! DateTime yesterdayAtClose = ! HistoricalEndOfDayTimer.GetMarketClose( yesterday ); double yesterdayMarketValueAtClose = historicalAdjustedQuoteProvider.GetMarketValue( ! ticker , yesterdayAtClose ); double dalyReturnForLongPosition = ( todayMarketValueAtClose / yesterdayMarketValueAtClose ) - 1; *************** *** 327,335 **** HistoricalAdjustedQuoteProvider historicalQuoteProvider = new HistoricalAdjustedQuoteProvider(); ! double previousQuote = historicalQuoteProvider.GetMarketValue( ticker , ! new EndOfDayDateTime( previousDate , EndOfDaySpecificTime.MarketClose ) ); ! double currentQuote = historicalQuoteProvider.GetMarketValue( ticker , ! new EndOfDayDateTime( currentDate , EndOfDaySpecificTime.MarketClose ) ); ! double closeToCloseReturn = currentQuote / previousQuote - 1.0; return closeToCloseReturn; } --- 327,337 ---- HistoricalAdjustedQuoteProvider historicalQuoteProvider = new HistoricalAdjustedQuoteProvider(); ! double previousMarketValue = historicalQuoteProvider.GetMarketValue( ! ticker , HistoricalEndOfDayTimer.GetMarketClose( previousDate ) ); ! // new EndOfDayDateTime( previousDate , EndOfDaySpecificTime.MarketClose ) ); ! double currentMarketValue = historicalQuoteProvider.GetMarketValue( ! ticker , HistoricalEndOfDayTimer.GetMarketClose( currentDate ) ); ! // new EndOfDayDateTime( currentDate , EndOfDaySpecificTime.MarketClose ) ); ! double closeToCloseReturn = currentMarketValue / previousMarketValue - 1.0; return closeToCloseReturn; } |
|
From: Glauco S. <gla...@us...> - 2008-09-29 21:18:03
|
Update of /cvsroot/quantproject/QuantProject/b4_Business/a2_Strategies/EquityEvaluation In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv16161/EquityEvaluation Modified Files: SharpeRatio.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: SharpeRatio.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b4_Business/a2_Strategies/EquityEvaluation/SharpeRatio.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** SharpeRatio.cs 10 Feb 2008 15:26:15 -0000 1.3 --- SharpeRatio.cs 29 Sep 2008 21:17:39 -0000 1.4 *************** *** 32,35 **** --- 32,36 ---- /// risk to reward Sharpe Ratio /// </summary> + [Serializable] public class SharpeRatio : IEquityEvaluator { |
|
From: Glauco S. <gla...@us...> - 2008-09-29 21:18:02
|
Update of /cvsroot/quantproject/QuantProject/b4_Business/a2_Strategies/EndOfDayStrategies In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv16161/EndOfDayStrategies Modified Files: SymmetricEndOfDayStrategyForBacktester.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: SymmetricEndOfDayStrategyForBacktester.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b4_Business/a2_Strategies/EndOfDayStrategies/SymmetricEndOfDayStrategyForBacktester.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** SymmetricEndOfDayStrategyForBacktester.cs 11 May 2008 16:56:17 -0000 1.2 --- SymmetricEndOfDayStrategyForBacktester.cs 29 Sep 2008 21:17:40 -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; --- 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,42 **** --- 39,43 ---- /// market open and market close events /// </summary> + [Serializable] public abstract class SymmetricEndOfDayStrategyForBacktester : BasicEndOfDayStrategyForBacktester *************** *** 49,61 **** IEligiblesSelector eligiblesSelector , IInSampleChooser inSampleChooser , ! IHistoricalQuoteProvider historicalQuoteProviderForInSample ) : base( ! numDaysBeetweenEachOtpimization , ! numDaysForInSampleOptimization , ! intervalsSelectorForInSample , ! intervalsSelectorForOutOfSample , ! eligiblesSelector , ! inSampleChooser , ! historicalQuoteProviderForInSample ) { // --- 50,62 ---- IEligiblesSelector eligiblesSelector , IInSampleChooser inSampleChooser , ! HistoricalMarketValueProvider historicalMarketValueProviderForInSample ) : base( ! numDaysBeetweenEachOtpimization , ! numDaysForInSampleOptimization , ! intervalsSelectorForInSample , ! intervalsSelectorForOutOfSample , ! eligiblesSelector , ! inSampleChooser , ! historicalMarketValueProviderForInSample ) { // |
|
From: Glauco S. <gla...@us...> - 2008-09-29 21:17:53
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/TechnicalAnalysisTesting/Oscillators/ExtremeCounterTrend In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv16104/Oscillators/ExtremeCounterTrend Modified Files: EndOfDayTimerHandlerECT.cs GenomeManagerECT.cs RunExtremeCounterTrend.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: EndOfDayTimerHandlerECT.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/TechnicalAnalysisTesting/Oscillators/ExtremeCounterTrend/EndOfDayTimerHandlerECT.cs,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** EndOfDayTimerHandlerECT.cs 19 Aug 2008 17:11:28 -0000 1.9 --- EndOfDayTimerHandlerECT.cs 29 Sep 2008 21:17:25 -0000 1.10 *************** *** 48,52 **** /// </summary> [Serializable] ! public class EndOfDayTimerHandlerECT : EndOfDayTimerHandler { private int numDaysForReturnCalculation; --- 48,53 ---- /// </summary> [Serializable] ! public class EndOfDayTimerHandlerECT : ! QuantProject.Scripts.TickerSelectionTesting.EfficientPortfolios.EndOfDayTimerHandler { private int numDaysForReturnCalculation; *************** *** 82,87 **** } ! public override void MarketOpenEventHandler( ! Object sender , EndOfDayTimingEventArgs endOfDayTimingEventArgs ) { ; --- 83,88 ---- } ! protected override void marketOpenEventHandler( ! Object sender , DateTime dateTime ) { ; *************** *** 89,93 **** ! #region MarketCloseEventHandler protected void marketCloseEventHandler_updateStopLossCondition() --- 90,94 ---- ! #region marketCloseEventHandler protected void marketCloseEventHandler_updateStopLossCondition() *************** *** 115,125 **** DateTime finalDateForHalfPeriod = (DateTime)timer.IndexQuotes.Rows[timer.CurrentDateArrayPosition]["quDate"]; ! ReturnsManager returnsManager = new ReturnsManager(new CloseToCloseIntervals( ! new EndOfDayDateTime(initialDateForHalfPeriod, ! EndOfDaySpecificTime.MarketClose) , ! new EndOfDayDateTime(finalDateForHalfPeriod, ! EndOfDaySpecificTime.MarketClose) , ! this.benchmark , this.numDaysForReturnCalculation ) , ! new HistoricalAdjustedQuoteProvider() ); returnValue = this.chosenWeightedPositions.GetReturn(0,returnsManager); } --- 116,130 ---- DateTime finalDateForHalfPeriod = (DateTime)timer.IndexQuotes.Rows[timer.CurrentDateArrayPosition]["quDate"]; ! ReturnsManager returnsManager = new ReturnsManager( ! new CloseToCloseIntervals( ! HistoricalEndOfDayTimer.GetMarketClose( initialDateForHalfPeriod ) , ! HistoricalEndOfDayTimer.GetMarketClose( finalDateForHalfPeriod ) , ! // new EndOfDayDateTime(initialDateForHalfPeriod, ! // EndOfDaySpecificTime.MarketClose) , ! // new EndOfDayDateTime(finalDateForHalfPeriod, ! // EndOfDaySpecificTime.MarketClose) , ! this.benchmark , ! this.numDaysForReturnCalculation ) , ! new HistoricalAdjustedQuoteProvider() ); returnValue = this.chosenWeightedPositions.GetReturn(0,returnsManager); } *************** *** 172,177 **** } ! public override void MarketCloseEventHandler( ! Object sender , EndOfDayTimingEventArgs endOfDayTimingEventArgs ) { if(this.account.Portfolio.Count > 0) --- 177,181 ---- } ! protected override void marketCloseEventHandler( Object sender , DateTime dateTime ) { if(this.account.Portfolio.Count > 0) *************** *** 190,194 **** #endregion ! #region OneHourAfterMarketCloseEventHandler --- 194,198 ---- #endregion ! #region oneHourAfterMarketCloseEventHandler *************** *** 298,305 **** /// <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++; --- 302,309 ---- /// <param name="sender"></param> /// <param name="eventArgs"></param> ! protected override void oneHourAfterMarketCloseEventHandler( ! Object sender , DateTime dateTime ) { ! this.lastCloseDate = dateTime; this.seedForRandomGenerator++; this.numDaysElapsedSinceLastOptimization++; *************** *** 309,313 **** //it is the first close (OLD IMPLEMENTATION) { ! this.setTickers(endOfDayTimingEventArgs.EndOfDayDateTime.DateTime, true); //sets tickers to be chosen next Market Close event this.numDaysElapsedSinceLastOptimization = 0; --- 313,317 ---- //it is the first close (OLD IMPLEMENTATION) { ! this.setTickers(dateTime, true); //sets tickers to be chosen next Market Close event this.numDaysElapsedSinceLastOptimization = 0; Index: GenomeManagerECT.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/TechnicalAnalysisTesting/Oscillators/ExtremeCounterTrend/GenomeManagerECT.cs,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** GenomeManagerECT.cs 14 Jan 2008 23:38:36 -0000 1.5 --- GenomeManagerECT.cs 29 Sep 2008 21:17:25 -0000 1.6 *************** *** 73,84 **** private void setReturnsManager() { ! EndOfDayDateTime firstEndOfDayDateTime = ! new EndOfDayDateTime(firstQuoteDate, EndOfDaySpecificTime.MarketClose); ! EndOfDayDateTime lastEndOfDayDateTime = ! new EndOfDayDateTime(lastQuoteDate, EndOfDaySpecificTime.MarketClose); this.returnsManager = new ReturnsManager( new CloseToCloseIntervals( ! firstEndOfDayDateTime, ! lastEndOfDayDateTime, this.benchmark, this.numDaysForReturnCalculation) , --- 73,86 ---- private void setReturnsManager() { ! DateTime firstDateTime = ! HistoricalEndOfDayTimer.GetMarketClose( firstQuoteDate ); ! // new EndOfDayDateTime(firstQuoteDate, EndOfDaySpecificTime.MarketClose); ! DateTime lastDateTime = ! HistoricalEndOfDayTimer.GetMarketClose( lastQuoteDate ); ! // new EndOfDayDateTime(lastQuoteDate, EndOfDaySpecificTime.MarketClose); this.returnsManager = new ReturnsManager( new CloseToCloseIntervals( ! firstDateTime, ! lastDateTime, this.benchmark, this.numDaysForReturnCalculation) , *************** *** 110,117 **** protected override float[] getStrategyReturns() { ! EndOfDayDateTime firstEndOfDayDateTime = ! new EndOfDayDateTime(firstQuoteDate, EndOfDaySpecificTime.MarketClose); ! EndOfDayDateTime lastEndOfDayDateTime = ! new EndOfDayDateTime(lastQuoteDate, EndOfDaySpecificTime.MarketClose); float[] plainReturns = this.weightedPositionsFromGenome.GetReturns( this.returnsManager); --- 112,121 ---- protected override float[] getStrategyReturns() { ! DateTime firstDateTime = ! HistoricalEndOfDayTimer.GetMarketClose( firstQuoteDate ); ! // new EndOfDayDateTime(firstQuoteDate, EndOfDaySpecificTime.MarketClose); ! DateTime lastDateTime = ! HistoricalEndOfDayTimer.GetMarketClose( lastQuoteDate ); ! // new EndOfDayDateTime(lastQuoteDate, EndOfDaySpecificTime.MarketClose); float[] plainReturns = this.weightedPositionsFromGenome.GetReturns( this.returnsManager); Index: RunExtremeCounterTrend.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/TechnicalAnalysisTesting/Oscillators/ExtremeCounterTrend/RunExtremeCounterTrend.cs,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** RunExtremeCounterTrend.cs 19 Aug 2008 17:13:06 -0000 1.5 --- RunExtremeCounterTrend.cs 29 Sep 2008 21:17:25 -0000 1.6 *************** *** 95,99 **** protected override void run_initializeHistoricalQuoteProvider() { ! this.historicalQuoteProvider = new HistoricalAdjustedQuoteProvider(); } --- 95,99 ---- protected override void run_initializeHistoricalQuoteProvider() { ! this.historicalMarketValueProvider = new HistoricalAdjustedQuoteProvider(); } *************** *** 101,115 **** { ! this.endOfDayTimer.MarketClose += ! new MarketCloseEventHandler( ! this.endOfDayTimerHandler.MarketCloseEventHandler); ! ! this.endOfDayTimer.MarketClose += ! new MarketCloseEventHandler( ! this.checkDateForReport); ! ! this.endOfDayTimer.OneHourAfterMarketClose += ! new OneHourAfterMarketCloseEventHandler( ! this.endOfDayTimerHandler.OneHourAfterMarketCloseEventHandler); } --- 101,120 ---- { ! 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); } *************** *** 134,138 **** //default report with numIntervalDays = 1 AccountReport accountReport = this.account.CreateReport(fileName,1, ! this.endOfDayTimer.GetCurrentTime(), this.benchmark, new HistoricalAdjustedQuoteProvider()); --- 139,143 ---- //default report with numIntervalDays = 1 AccountReport accountReport = this.account.CreateReport(fileName,1, ! this.endOfDayTimer.GetCurrentDateTime(), this.benchmark, new HistoricalAdjustedQuoteProvider()); |
|
From: Glauco S. <gla...@us...> - 2008-09-29 21:17:45
|
Update of /cvsroot/quantproject/QuantProject/b4_Business/a2_Strategies/TickersRelationships In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv16037/TickersRelationships Modified Files: OpenToCloseCorrelationProvider.cs OpenToOpenCorrelationProvider.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: OpenToOpenCorrelationProvider.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b4_Business/a2_Strategies/TickersRelationships/OpenToOpenCorrelationProvider.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** OpenToOpenCorrelationProvider.cs 14 Aug 2008 23:37:13 -0000 1.1 --- OpenToOpenCorrelationProvider.cs 29 Sep 2008 21:17:15 -0000 1.2 *************** *** 89,98 **** } ! protected override void setEndOfDayDatesTime(DateTime startDate, DateTime endDate) { ! this.firstEndOfDayDateTime = ! new EndOfDayDateTime(startDate, EndOfDaySpecificTime.MarketOpen); ! this.lastEndOfDayDateTime = ! new EndOfDayDateTime(endDate, EndOfDaySpecificTime.MarketOpen); } --- 89,101 ---- } ! protected override void setEndOfDayDatesTime( ! DateTime firstDate , DateTime lastDate ) { ! this.firstDateTime = ! HistoricalEndOfDayTimer.GetMarketOpen( firstDate ); ! // new EndOfDayDateTime(firstDate, EndOfDaySpecificTime.MarketOpen); ! this.lastDateTime = ! HistoricalEndOfDayTimer.GetMarketOpen( lastDate ); ! // new EndOfDayDateTime(lastDate, EndOfDaySpecificTime.MarketOpen); } *************** *** 100,104 **** { OpenToOpenIntervals openToOpenIntervals = ! new OpenToOpenIntervals(this.firstEndOfDayDateTime, this.lastEndOfDayDateTime, this.benchmark, this.openToOpenIntervalLength); this.returnsManager = --- 103,107 ---- { OpenToOpenIntervals openToOpenIntervals = ! new OpenToOpenIntervals(this.firstDateTime, this.lastDateTime, this.benchmark, this.openToOpenIntervalLength); this.returnsManager = Index: OpenToCloseCorrelationProvider.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b4_Business/a2_Strategies/TickersRelationships/OpenToCloseCorrelationProvider.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** OpenToCloseCorrelationProvider.cs 14 Jan 2008 23:02:30 -0000 1.1 --- OpenToCloseCorrelationProvider.cs 29 Sep 2008 21:17:15 -0000 1.2 *************** *** 86,95 **** } ! protected override void setEndOfDayDatesTime(DateTime startDate, DateTime endDate) { ! this.firstEndOfDayDateTime = ! new EndOfDayDateTime(startDate, EndOfDaySpecificTime.MarketOpen); ! this.lastEndOfDayDateTime = ! new EndOfDayDateTime(endDate, EndOfDaySpecificTime.MarketClose); } --- 86,98 ---- } ! protected override void setEndOfDayDatesTime( ! DateTime firstDate , DateTime lastDate ) { ! this.firstDateTime = ! HistoricalEndOfDayTimer.GetMarketOpen( firstDate ); ! // new EndOfDayDateTime(firstDate, EndOfDaySpecificTime.MarketOpen); ! this.lastDateTime = ! HistoricalEndOfDayTimer.GetMarketClose( lastDate ); ! // new EndOfDayDateTime(lastDate, EndOfDaySpecificTime.MarketClose); } *************** *** 97,101 **** { DailyOpenToCloseIntervals dailyOpenToCloseIntervals = ! new DailyOpenToCloseIntervals(this.firstEndOfDayDateTime, this.lastEndOfDayDateTime, this.benchmark); this.returnsManager = --- 100,104 ---- { DailyOpenToCloseIntervals dailyOpenToCloseIntervals = ! new DailyOpenToCloseIntervals(this.firstDateTime, this.lastDateTime, this.benchmark); this.returnsManager = |
|
From: Glauco S. <gla...@us...> - 2008-09-29 21:17:35
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/SimpleTesting/ShortTest In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv15980/ShortTest Modified Files: EndOfDayTimerHandler.cs RunShortTest.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: RunShortTest.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/SimpleTesting/ShortTest/RunShortTest.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** RunShortTest.cs 20 Feb 2005 00:05:11 -0000 1.1 --- RunShortTest.cs 29 Sep 2008 21:17:09 -0000 1.2 *************** *** 3,7 **** RunShortTest.cs ! Copyright (C) 2003 Glauco Siliprandi --- 3,7 ---- RunShortTest.cs ! Copyright (C) 2003 Glauco Siliprandi *************** *** 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; *************** *** 42,46 **** private DateTime endDateTime = new DateTime( 2000 , 12 , 31 ); private Account account; ! private IHistoricalQuoteProvider historicalQuoteProvider = new HistoricalAdjustedQuoteProvider(); /// <summary> --- 42,46 ---- private DateTime endDateTime = new DateTime( 2000 , 12 , 31 ); private Account account; ! private HistoricalMarketValueProvider historicalMarketValueProvider = new HistoricalAdjustedQuoteProvider(); /// <summary> *************** *** 54,59 **** HistoricalEndOfDayTimer historicalEndOfDayTimer = new IndexBasedEndOfDayTimer( ! new EndOfDayDateTime( this.startDateTime , ! EndOfDaySpecificTime.MarketOpen ) , "MSFT" ); // this.account = new Account( "MSFT" , historicalEndOfDayTimer , // new HistoricalEndOfDayDataStreamer( historicalEndOfDayTimer , --- 54,61 ---- HistoricalEndOfDayTimer historicalEndOfDayTimer = new IndexBasedEndOfDayTimer( ! HistoricalEndOfDayTimer.GetMarketOpen( this.startDateTime ) , ! // new EndOfDayDateTime( this.startDateTime , ! // EndOfDaySpecificTime.MarketOpen ) , ! "MSFT" ); // this.account = new Account( "MSFT" , historicalEndOfDayTimer , // new HistoricalEndOfDayDataStreamer( historicalEndOfDayTimer , *************** *** 63,80 **** // new IBCommissionManager() ); this.account = new Account( "MSFT" , historicalEndOfDayTimer , ! new HistoricalEndOfDayDataStreamer( historicalEndOfDayTimer , ! this.historicalQuoteProvider ) , ! new HistoricalEndOfDayOrderExecutor( historicalEndOfDayTimer , ! this.historicalQuoteProvider ) ); ! EndOfDayTimerHandler EndOfDayTimerHandler = new EndOfDayTimerHandler( this.account , endDateTime ); ! historicalEndOfDayTimer.MarketOpen += new MarketOpenEventHandler( ! EndOfDayTimerHandler.MarketOpenEventHandler ); ! historicalEndOfDayTimer.MarketClose += new MarketCloseEventHandler( ! EndOfDayTimerHandler.MarketCloseEventHandler ); ! this.account.EndOfDayTimer.Start(); ! Report report = new Report( this.account , this.historicalQuoteProvider ); ! report.Show( "WFT One Rank" , 1 , ! new EndOfDayDateTime( this.endDateTime , EndOfDaySpecificTime.MarketClose ) , "MSFT" ); } --- 65,87 ---- // new IBCommissionManager() ); this.account = new Account( "MSFT" , historicalEndOfDayTimer , ! new HistoricalEndOfDayDataStreamer( historicalEndOfDayTimer , ! this.historicalMarketValueProvider ) , ! new HistoricalEndOfDayOrderExecutor( historicalEndOfDayTimer , ! this.historicalMarketValueProvider ) ); ! EndOfDayTimerHandler endOfDayTimerHandler = new EndOfDayTimerHandler( this.account , endDateTime ); ! historicalEndOfDayTimer.NewDateTime += ! new NewDateTimeEventHandler( endOfDayTimerHandler.NewDateTimeEventHandler ); ! ! // historicalEndOfDayTimer.MarketOpen += new MarketOpenEventHandler( ! // endOfDayTimerHandler.MarketOpenEventHandler ); ! // historicalEndOfDayTimer.MarketClose += new MarketCloseEventHandler( ! // endOfDayTimerHandler.MarketCloseEventHandler ); ! this.account.Timer.Start(); ! Report report = new Report( this.account , this.historicalMarketValueProvider ); ! report.Show( ! "WFT One Rank" , 1 , ! HistoricalEndOfDayTimer.GetMarketClose( this.endDateTime ) , ! // new EndOfDayDateTime( this.endDateTime , EndOfDaySpecificTime.MarketClose ) , "MSFT" ); } Index: EndOfDayTimerHandler.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/SimpleTesting/ShortTest/EndOfDayTimerHandler.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** EndOfDayTimerHandler.cs 20 Feb 2005 00:05:11 -0000 1.1 --- EndOfDayTimerHandler.cs 29 Sep 2008 21:17:08 -0000 1.2 *************** *** 3,7 **** EndOfDayTimerHandler.cs ! Copyright (C) 2003 Glauco Siliprandi --- 3,7 ---- EndOfDayTimerHandler.cs ! Copyright (C) 2003 Glauco Siliprandi *************** *** 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.Collections; --- 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.Collections; *************** *** 36,40 **** /// Short Test core strategy /// </summary> ! public class EndOfDayTimerHandler { --- 36,41 ---- /// Short Test core strategy /// </summary> ! public class EndOfDayTimerHandler : ! QuantProject.Business.Strategies.EndOfDayTimerHandler { *************** *** 58,62 **** /// best performing ticker calculation</param> public EndOfDayTimerHandler( Account account , ! DateTime endDateTime ) { this.account = account; --- 59,63 ---- /// best performing ticker calculation</param> public EndOfDayTimerHandler( Account account , ! DateTime endDateTime ) { this.account = account; *************** *** 68,86 **** /// <param name="sender"></param> /// <param name="eventArgs"></param> ! public void MarketOpenEventHandler( ! Object sender , EndOfDayTimingEventArgs endOfDayTimingEventArgs ) { this.account.AddOrder( new Order( OrderType.MarketSellShort , ! new Instrument( "MSFT" ) , 100 ) ); } ! public void MarketCloseEventHandler( ! Object sender , EndOfDayTimingEventArgs endOfDayTimingEventArgs ) { this.account.ClosePosition( "MSFT" ); ! if ( this.account.EndOfDayTimer.GetCurrentTime().DateTime > ! this.endDateTime ) ! this.account.EndOfDayTimer.Stop(); } } } --- 69,95 ---- /// <param name="sender"></param> /// <param name="eventArgs"></param> ! protected override void marketOpenEventHandler( ! Object sender , DateTime dateTime ) { this.account.AddOrder( new Order( OrderType.MarketSellShort , ! new Instrument( "MSFT" ) , 100 ) ); } ! protected override void marketCloseEventHandler( ! Object sender , DateTime dateTime ) { this.account.ClosePosition( "MSFT" ); ! if ( this.account.Timer.GetCurrentDateTime() > ! this.endDateTime ) ! this.account.Timer.Stop(); } + protected override void oneHourAfterMarketCloseEventHandler( + Object sender , DateTime dateTime ) + { + this.account.ClosePosition( "MSFT" ); + if ( this.account.Timer.GetCurrentDateTime() > + this.endDateTime ) + this.account.Timer.Stop(); + } } } |
|
From: Glauco S. <gla...@us...> - 2008-09-29 21:17:30
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/ArbitrageTesting/PairTrading/SimplePairTrading In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv15453/PairTrading/SimplePairTrading Modified Files: EndOfDayTimerHandlerSimplePT.cs RunSimplePairTrading.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: EndOfDayTimerHandlerSimplePT.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/ArbitrageTesting/PairTrading/SimplePairTrading/EndOfDayTimerHandlerSimplePT.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** EndOfDayTimerHandlerSimplePT.cs 14 May 2006 15:25:30 -0000 1.1 --- EndOfDayTimerHandlerSimplePT.cs 29 Sep 2008 21:16:41 -0000 1.2 *************** *** 3,7 **** EndOfDayTimerHandlerSimplePT.cs ! Copyright (C) 2003 Marco Milletti --- 3,7 ---- EndOfDayTimerHandlerSimplePT.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; 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; *************** *** 28,31 **** --- 28,32 ---- using QuantProject.Business.Financial.Instruments; using QuantProject.Business.Financial.Ordering; + using QuantProject.Business.Strategies; using QuantProject.Business.Timing; using QuantProject.Business.DataProviders; *************** *** 40,365 **** { ! /// <summary> ! /// Implements MarketOpenEventHandler, ! /// MarketCloseEventHandler and OneHourAfterMarketCloseEventHandler ! /// for the implementation of the simple pair trading strategy ! /// </summary> ! [Serializable] ! public class EndOfDayTimerHandlerSimplePT ! { ! private string tickerGroupID; ! protected string[] chosenTickers = new string[10]; ! //this array is designed for containing ! //five couples of eligible tickers for ! //the pair trading strategy ! protected double[] averageGapsOfChosenTickers = new double[10]; ! protected double[] stdDevGapsOfChosenTickers = new double[10]; ! protected string[] lastOrderedTickers = new string[2]; ! protected int addedTickersCounter = 0; ! protected float currentPair_firstTickerGain = 0.0F; ! protected float currentPair_secondTickerGain = 0.0F; ! ! private int numberOfEligibleTickers; ! private int numDaysForOptimizationPeriod; ! private int generationNumberForGeneticOptimizer; ! private int populationSizeForGeneticOptimizer; ! protected string benchmark; ! protected DateTime startDate; ! protected DateTime endDate; ! protected double maxNumOfStdDevForNormalGap; ! private double maxLevelForNormalGap; ! private int minNumOfDaysForGapComputation; ! private int maxNumOfDaysForGapComputation; ! private int numDaysBetweenEachOptimization; ! private int numDaysElapsedSinceLastOptimization; ! private double maxRunningHours; ! protected Account account; ! private int seedForRandomGenerator; ! protected double minimumGainForClosingPositions; ! protected double maximumToleratedLoss; ! protected double initialAccountValue = 0.0; ! protected int counterForDaysWithPositions = 0; ! protected int currentNumDaysForGapComputation; ! //it stores the value for the new account ! protected HistoricalAdjustedQuoteProvider historicalAdjustedQuoteProvider; ! private OptimizationOutput optimizationOutput; ! ! public OptimizationOutput OptimizationOutput ! { ! get{return this.optimizationOutput;} ! } ! public EndOfDayTimerHandlerSimplePT(string tickerGroupID, int numberOfEligibleTickers, ! int numDaysForOptimizationPeriod, ! int generationNumberForGeneticOptimizer, ! int populationSizeForGeneticOptimizer, ! string benchmark, ! DateTime startDate, DateTime endDate, ! double maxNumOfStdDevForNormalGap, int minNumOfDaysForGapComputation, ! int maxNumOfDaysForGapComputation, int numDaysBetweenEachOptimization, ! double maxRunningHours, ! Account account) ! { ! this.tickerGroupID = tickerGroupID; ! this.numberOfEligibleTickers = numberOfEligibleTickers; ! this.numDaysForOptimizationPeriod = numDaysForOptimizationPeriod; ! this.generationNumberForGeneticOptimizer = generationNumberForGeneticOptimizer; ! this.populationSizeForGeneticOptimizer = populationSizeForGeneticOptimizer; ! this.benchmark = benchmark; ! this.startDate = startDate; ! this.endDate = endDate; ! this.maxNumOfStdDevForNormalGap = maxNumOfStdDevForNormalGap; ! this.minNumOfDaysForGapComputation = minNumOfDaysForGapComputation; ! this.maxNumOfDaysForGapComputation = maxNumOfDaysForGapComputation; ! this.numDaysBetweenEachOptimization = numDaysBetweenEachOptimization; ! this.maxRunningHours = maxRunningHours; ! this.account = account; ! this.numDaysElapsedSinceLastOptimization = 0; ! this.seedForRandomGenerator = ConstantsProvider.SeedForRandomGenerator; ! this.historicalAdjustedQuoteProvider = new HistoricalAdjustedQuoteProvider(); ! this.minimumGainForClosingPositions = 0.002; ! this.maximumToleratedLoss = 0.02; ! this.optimizationOutput = new OptimizationOutput(); ! } ! ! public void MarketOpenEventHandler( ! Object sender , EndOfDayTimingEventArgs endOfDayTimingEventArgs ) ! { ! ! } ! ! #region MarketCloseEventHandler ! ! public void marketCloseEventHandler_closePositions() ! { ! if(this.account.Portfolio[ this.lastOrderedTickers[0] ] != null) ! this.account.ClosePosition( this.lastOrderedTickers[0] ); ! if(this.account.Portfolio[ this.lastOrderedTickers[1] ] != null) ! this.account.ClosePosition( this.lastOrderedTickers[1] ); ! } ! ! private bool marketCloseEventHandler_isCurrentGainGoodEnoughOrStopLossConditionReached(EndOfDayDateTime currentEndOfDayDateTime) ! { ! bool returnValue = false; ! double currentGain = ! (this.account.GetMarketValue() - this.initialAccountValue)/ ! this.initialAccountValue; ! if(currentGain >= this.minimumGainForClosingPositions || ! -currentGain >= this.maximumToleratedLoss) ! //gain is good enough or loss is too high ... ! returnValue = true; ! return returnValue; ! } ! ! private float marketCloseEventHandler_openPositions_getGap(int indexForPair, ! DateTime firstDate, ! DateTime lastDate) ! { ! Quotes firstTickerQuotes = new Quotes(this.chosenTickers[indexForPair], firstDate, lastDate); ! Quotes secondTickerQuotes = new Quotes(this.chosenTickers[indexForPair+1], firstDate, lastDate); ! this.currentPair_firstTickerGain = ! (float)firstTickerQuotes.Rows[1]["quClose"]/(float)firstTickerQuotes.Rows[0]["quClose"]; ! this.currentPair_secondTickerGain = ! (float)secondTickerQuotes.Rows[1]["quClose"]/(float)secondTickerQuotes.Rows[0]["quClose"]; ! return (this.currentPair_firstTickerGain - this.currentPair_secondTickerGain); ! } ! ! private void marketCloseEventHandler_openPositions_open(int indexForPair) ! ! { ! double cashForSinglePosition = this.account.CashAmount/2; ! long quantityForFirstTicker = ! Convert.ToInt64( Math.Floor( cashForSinglePosition / this.account.DataStreamer.GetCurrentBid( this.chosenTickers[indexForPair] ) ) ); ! long quantityForSecondTicker = ! Convert.ToInt64( Math.Floor( cashForSinglePosition / this.account.DataStreamer.GetCurrentBid( this.chosenTickers[indexForPair+1] ) ) ); ! OrderType orderTypeForFirstTicker = OrderType.MarketBuy; ! OrderType orderTypeForSecondTicker = OrderType.MarketSellShort; ! if(this.currentPair_firstTickerGain > this.currentPair_secondTickerGain) ! { ! orderTypeForFirstTicker = OrderType.MarketSellShort; ! orderTypeForSecondTicker = OrderType.MarketBuy; ! } ! this.account.AddOrder(new Order( orderTypeForFirstTicker, ! new Instrument( this.chosenTickers[indexForPair] ) , ! quantityForFirstTicker )); ! this.account.AddOrder(new Order( orderTypeForSecondTicker, ! new Instrument( this.chosenTickers[indexForPair+1] ) , ! quantityForSecondTicker )); ! this.lastOrderedTickers[0] = this.chosenTickers[indexForPair]; ! this.lastOrderedTickers[1] = this.chosenTickers[indexForPair+1]; ! } ! ! private void marketCloseEventHandler_openPositions_setMaxLevelForNormalGap(int indexForPair) ! ! { ! this.maxLevelForNormalGap = this.averageGapsOfChosenTickers[indexForPair] + ! this.maxNumOfStdDevForNormalGap * ! this.stdDevGapsOfChosenTickers[indexForPair]; ! } ! ! private void marketCloseEventHandler_openPositions(EndOfDayDateTime currentEndOfDayDateTime, ! IndexBasedEndOfDayTimer timer) ! { ! if(this.chosenTickers[0] != null) ! //potential tickers for pair trading have been set ! { ! for(int i = 0; i<this.chosenTickers.Length - 1 && ! this.account.Portfolio.Count == 0; i++) ! { ! this.marketCloseEventHandler_openPositions_setMaxLevelForNormalGap(i); ! if(Math.Abs(this.marketCloseEventHandler_openPositions_getGap(i, timer.GetPreviousDateTime(), ! timer.GetCurrentTime().DateTime)) >= (float)this.maxLevelForNormalGap) ! //currentGap is too high for being considered rational ! //so there is an arbitrage opportunity ! this.marketCloseEventHandler_openPositions_open(i); ! } ! this.initialAccountValue = this.account.GetMarketValue(); ! //this.account.Portfolio.GetMarketValue(currentEndOfDayDateTime,this.historicalAdjustedQuoteProvider); ! } ! } ! ! public virtual void MarketCloseEventHandler( ! Object sender , EndOfDayTimingEventArgs endOfDayTimingEventArgs ) ! { ! if(this.account.Portfolio.Count == 0) ! //portfolio is empty ! { ! if(this.account.Transactions.Count == 0) ! this.account.AddCash(30000); ! this.marketCloseEventHandler_openPositions(endOfDayTimingEventArgs.EndOfDayDateTime, ! (IndexBasedEndOfDayTimer)sender); ! } ! else // portfolio is not empty ! { ! this.counterForDaysWithPositions++; ! if(this.counterForDaysWithPositions == this.currentNumDaysForGapComputation || ! this.marketCloseEventHandler_isCurrentGainGoodEnoughOrStopLossConditionReached(endOfDayTimingEventArgs.EndOfDayDateTime)) ! //a number of days equal to the number of days ! //used for gap computation has elapsed or ! //the current gain is good enough or ! //loss is too high ! { ! this.marketCloseEventHandler_closePositions(); ! this.counterForDaysWithPositions = 0; ! } ! ! } ! } ! #endregion ! #region OneHourAfterMarketCloseEventHandler ! ! protected DataTable getSetOfTickersToBeOptimized(DateTime currentDate) ! { ! SelectorByGroup temporizedGroup = new SelectorByGroup(this.tickerGroupID, currentDate); ! SelectorByQuotationAtEachMarketDay quotedAtEachMarketDayFromEligible = ! new SelectorByQuotationAtEachMarketDay( temporizedGroup.GetTableOfSelectedTickers(), ! false, currentDate.AddDays(-this.numDaysForOptimizationPeriod), ! currentDate, this.numberOfEligibleTickers, this.benchmark); ! return quotedAtEachMarketDayFromEligible.GetTableOfSelectedTickers(); ! } ! ! private void setTickers_setChosenTickers_addGenomeForOptimizationOutput(Genome genome, DateTime currentDate) ! { ! this.optimizationOutput.Add(new GenomeRepresentation(this.maxNumOfStdDevForNormalGap, ! genome, ! currentDate.AddDays(-this.numDaysForOptimizationPeriod), ! currentDate)); ! } ! private void setTickers_setChosenTickers_addTickers(Genome genome) ! { ! this.chosenTickers[this.addedTickersCounter] = ! ((GenomeMeaningSimplePT)genome.Meaning).FirstTicker; ! this.chosenTickers[this.addedTickersCounter+1] = ! ((GenomeMeaningSimplePT)genome.Meaning).SecondTicker; ! ! this.averageGapsOfChosenTickers[this.addedTickersCounter] = ! ((GenomeMeaningSimplePT)genome.Meaning).AverageGap; ! this.stdDevGapsOfChosenTickers[this.addedTickersCounter] = ! ((GenomeMeaningSimplePT)genome.Meaning).StdDevGap; ! this.currentNumDaysForGapComputation = ((GenomeMeaningSimplePT)genome.Meaning).NumOfDaysForGap; ! ! this.addedTickersCounter += 2; ! } ! ! private bool setTickers_setChosenTickers_isAnyTickerOfGenomeInChosenTickers(Genome genome) ! { ! bool returnValue = false; ! foreach(string ticker in this.chosenTickers) ! { ! if(ticker == ((GenomeMeaningSimplePT)genome.Meaning).FirstTicker || ! ticker == ((GenomeMeaningSimplePT)genome.Meaning).SecondTicker) ! returnValue = true; ! } ! return returnValue; ! } ! ! private void setTickers_setChosenTickers(GeneticOptimizer GO, DateTime currentDate) ! { ! this.addedTickersCounter = 0; ! for(int i = 0; ! i<GO.CurrentGeneration.Count -1 && ! addedTickersCounter<this.chosenTickers.Length; ! i++) ! { ! Genome currentGenome = (Genome)GO.CurrentGeneration[GO.CurrentGeneration.Count-i-1]; ! if(!this.setTickers_setChosenTickers_isAnyTickerOfGenomeInChosenTickers(currentGenome)) ! { ! this.setTickers_setChosenTickers_addTickers(currentGenome); ! this.setTickers_setChosenTickers_addGenomeForOptimizationOutput(currentGenome, ! currentDate); ! } ! } ! } ! private void setTickers(DateTime currentDate) ! { ! ! DataTable setOfTickersToBeOptimized = this.getSetOfTickersToBeOptimized(currentDate); ! IGenomeManager genManForSimplePT = ! new GenomeManagerForSimplePT(setOfTickersToBeOptimized, ! currentDate.AddDays(-this.numDaysForOptimizationPeriod), ! currentDate, ! this.minNumOfDaysForGapComputation, ! this.maxNumOfDaysForGapComputation, ! this.maxNumOfStdDevForNormalGap); ! ! GeneticOptimizer GO = new GeneticOptimizer(genManForSimplePT, ! this.populationSizeForGeneticOptimizer, ! this.generationNumberForGeneticOptimizer, ! this.seedForRandomGenerator); ! GO.Run(false); ! this.setTickers_setChosenTickers(GO, currentDate); ! } ! /// <summary> ! /// Handles a "One hour after market close" event. ! /// </summary> ! /// <param name="sender"></param> ! /// <param name="eventArgs"></param> ! public virtual void OneHourAfterMarketCloseEventHandler( ! Object sender , EndOfDayTimingEventArgs endOfDayTimingEventArgs ) ! { ! this.seedForRandomGenerator++; ! if(this.numDaysElapsedSinceLastOptimization == ! this.numDaysBetweenEachOptimization - 1) ! { ! this.setTickers(endOfDayTimingEventArgs.EndOfDayDateTime.DateTime); ! //sets tickers to be chosen at next Market Open event ! this.numDaysElapsedSinceLastOptimization = 0; ! } ! else ! { ! this.numDaysElapsedSinceLastOptimization++; ! } ! } ! ! #endregion ! } } --- 41,368 ---- { ! /// <summary> ! /// Implements MarketOpenEventHandler, ! /// MarketCloseEventHandler and OneHourAfterMarketCloseEventHandler ! /// for the implementation of the simple pair trading strategy ! /// </summary> ! [Serializable] ! public class EndOfDayTimerHandlerSimplePT : EndOfDayStrategy ! { ! private string tickerGroupID; ! protected string[] chosenTickers = new string[10]; ! //this array is designed for containing ! //five couples of eligible tickers for ! //the pair trading strategy ! protected double[] averageGapsOfChosenTickers = new double[10]; ! protected double[] stdDevGapsOfChosenTickers = new double[10]; ! protected string[] lastOrderedTickers = new string[2]; ! protected int addedTickersCounter = 0; ! protected float currentPair_firstTickerGain = 0.0F; ! protected float currentPair_secondTickerGain = 0.0F; ! ! private int numberOfEligibleTickers; ! private int numDaysForOptimizationPeriod; ! private int generationNumberForGeneticOptimizer; ! private int populationSizeForGeneticOptimizer; ! protected string benchmark; ! protected DateTime startDate; ! protected DateTime endDate; ! protected double maxNumOfStdDevForNormalGap; ! private double maxLevelForNormalGap; ! private int minNumOfDaysForGapComputation; ! private int maxNumOfDaysForGapComputation; ! private int numDaysBetweenEachOptimization; ! private int numDaysElapsedSinceLastOptimization; ! private double maxRunningHours; ! // protected Account account; ! private int seedForRandomGenerator; ! protected double minimumGainForClosingPositions; ! protected double maximumToleratedLoss; ! protected double initialAccountValue = 0.0; ! protected int counterForDaysWithPositions = 0; ! protected int currentNumDaysForGapComputation; ! //it stores the value for the new account ! protected HistoricalAdjustedQuoteProvider historicalAdjustedQuoteProvider; ! private OptimizationOutput optimizationOutput; ! ! public OptimizationOutput OptimizationOutput ! { ! get{return this.optimizationOutput;} ! } ! public EndOfDayTimerHandlerSimplePT(string tickerGroupID, int numberOfEligibleTickers, ! int numDaysForOptimizationPeriod, ! int generationNumberForGeneticOptimizer, ! int populationSizeForGeneticOptimizer, ! string benchmark, ! DateTime startDate, DateTime endDate, ! double maxNumOfStdDevForNormalGap, int minNumOfDaysForGapComputation, ! int maxNumOfDaysForGapComputation, int numDaysBetweenEachOptimization, ! double maxRunningHours, ! Account account) ! { ! this.tickerGroupID = tickerGroupID; ! this.numberOfEligibleTickers = numberOfEligibleTickers; ! this.numDaysForOptimizationPeriod = numDaysForOptimizationPeriod; ! this.generationNumberForGeneticOptimizer = generationNumberForGeneticOptimizer; ! this.populationSizeForGeneticOptimizer = populationSizeForGeneticOptimizer; ! this.benchmark = benchmark; ! this.startDate = startDate; ! this.endDate = endDate; ! this.maxNumOfStdDevForNormalGap = maxNumOfStdDevForNormalGap; ! this.minNumOfDaysForGapComputation = minNumOfDaysForGapComputation; ! this.maxNumOfDaysForGapComputation = maxNumOfDaysForGapComputation; ! this.numDaysBetweenEachOptimization = numDaysBetweenEachOptimization; ! this.maxRunningHours = maxRunningHours; ! this.account = account; ! this.numDaysElapsedSinceLastOptimization = 0; ! this.seedForRandomGenerator = ConstantsProvider.SeedForRandomGenerator; ! this.historicalAdjustedQuoteProvider = new HistoricalAdjustedQuoteProvider(); ! this.minimumGainForClosingPositions = 0.002; ! this.maximumToleratedLoss = 0.02; ! this.optimizationOutput = new OptimizationOutput(); ! } ! ! protected override void marketOpenEventHandler( ! Object sender , DateTime dateTime ) ! { ! ! } ! ! #region marketCloseEventHandler ! ! public void marketCloseEventHandler_closePositions() ! { ! if(this.account.Portfolio[ this.lastOrderedTickers[0] ] != null) ! this.account.ClosePosition( this.lastOrderedTickers[0] ); ! if(this.account.Portfolio[ this.lastOrderedTickers[1] ] != null) ! this.account.ClosePosition( this.lastOrderedTickers[1] ); ! } ! ! private bool marketCloseEventHandler_isCurrentGainGoodEnoughOrStopLossConditionReached( ! DateTime currentDateTime ) ! { ! bool returnValue = false; ! double currentGain = ! (this.account.GetMarketValue() - this.initialAccountValue)/ ! this.initialAccountValue; ! if(currentGain >= this.minimumGainForClosingPositions || ! -currentGain >= this.maximumToleratedLoss) ! //gain is good enough or loss is too high ... ! returnValue = true; ! return returnValue; ! } ! ! private float marketCloseEventHandler_openPositions_getGap(int indexForPair, ! DateTime firstDate, ! DateTime lastDate) ! { ! Quotes firstTickerQuotes = new Quotes(this.chosenTickers[indexForPair], firstDate, lastDate); ! Quotes secondTickerQuotes = new Quotes(this.chosenTickers[indexForPair+1], firstDate, lastDate); ! this.currentPair_firstTickerGain = ! (float)firstTickerQuotes.Rows[1]["quClose"]/(float)firstTickerQuotes.Rows[0]["quClose"]; ! this.currentPair_secondTickerGain = ! (float)secondTickerQuotes.Rows[1]["quClose"]/(float)secondTickerQuotes.Rows[0]["quClose"]; ! return (this.currentPair_firstTickerGain - this.currentPair_secondTickerGain); ! } ! ! private void marketCloseEventHandler_openPositions_open(int indexForPair) ! ! { ! double cashForSinglePosition = this.account.CashAmount/2; ! long quantityForFirstTicker = ! Convert.ToInt64( Math.Floor( cashForSinglePosition / this.account.DataStreamer.GetCurrentBid( this.chosenTickers[indexForPair] ) ) ); ! long quantityForSecondTicker = ! Convert.ToInt64( Math.Floor( cashForSinglePosition / this.account.DataStreamer.GetCurrentBid( this.chosenTickers[indexForPair+1] ) ) ); ! OrderType orderTypeForFirstTicker = OrderType.MarketBuy; ! OrderType orderTypeForSecondTicker = OrderType.MarketSellShort; ! if(this.currentPair_firstTickerGain > this.currentPair_secondTickerGain) ! { ! orderTypeForFirstTicker = OrderType.MarketSellShort; ! orderTypeForSecondTicker = OrderType.MarketBuy; ! } ! this.account.AddOrder(new Order( orderTypeForFirstTicker, ! new Instrument( this.chosenTickers[indexForPair] ) , ! quantityForFirstTicker )); ! this.account.AddOrder(new Order( orderTypeForSecondTicker, ! new Instrument( this.chosenTickers[indexForPair+1] ) , ! quantityForSecondTicker )); ! this.lastOrderedTickers[0] = this.chosenTickers[indexForPair]; ! this.lastOrderedTickers[1] = this.chosenTickers[indexForPair+1]; ! } ! ! private void marketCloseEventHandler_openPositions_setMaxLevelForNormalGap(int indexForPair) ! ! { ! this.maxLevelForNormalGap = this.averageGapsOfChosenTickers[indexForPair] + ! this.maxNumOfStdDevForNormalGap * ! this.stdDevGapsOfChosenTickers[indexForPair]; ! } ! ! private void marketCloseEventHandler_openPositions( ! DateTime currentDateTime , IndexBasedEndOfDayTimer timer ) ! { ! if(this.chosenTickers[0] != null) ! //potential tickers for pair trading have been set ! { ! for(int i = 0; i<this.chosenTickers.Length - 1 && ! this.account.Portfolio.Count == 0; i++) ! { ! this.marketCloseEventHandler_openPositions_setMaxLevelForNormalGap(i); ! if(Math.Abs(this.marketCloseEventHandler_openPositions_getGap( ! i, timer.GetPreviousDateTime(), ! timer.GetCurrentDateTime())) >= (float)this.maxLevelForNormalGap) ! //currentGap is too high for being considered rational ! //so there is an arbitrage opportunity ! this.marketCloseEventHandler_openPositions_open(i); ! } ! this.initialAccountValue = this.account.GetMarketValue(); ! //this.account.Portfolio.GetMarketValue(currentEndOfDayDateTime,this.historicalAdjustedQuoteProvider); ! } ! } ! ! protected override void marketCloseEventHandler( ! Object sender , DateTime dateTime ) ! { ! if(this.account.Portfolio.Count == 0) ! //portfolio is empty ! { ! if(this.account.Transactions.Count == 0) ! this.account.AddCash(30000); ! this.marketCloseEventHandler_openPositions(dateTime, ! (IndexBasedEndOfDayTimer)sender); ! } ! else // portfolio is not empty ! { ! this.counterForDaysWithPositions++; ! if(this.counterForDaysWithPositions == this.currentNumDaysForGapComputation || ! this.marketCloseEventHandler_isCurrentGainGoodEnoughOrStopLossConditionReached(dateTime)) ! //a number of days equal to the number of days ! //used for gap computation has elapsed or ! //the current gain is good enough or ! //loss is too high ! { ! this.marketCloseEventHandler_closePositions(); ! this.counterForDaysWithPositions = 0; ! } ! ! } ! } ! #endregion ! #region oneHourAfterMarketCloseEventHandler ! ! protected DataTable getSetOfTickersToBeOptimized(DateTime currentDate) ! { ! SelectorByGroup temporizedGroup = new SelectorByGroup(this.tickerGroupID, currentDate); ! SelectorByQuotationAtEachMarketDay quotedAtEachMarketDayFromEligible = ! new SelectorByQuotationAtEachMarketDay( temporizedGroup.GetTableOfSelectedTickers(), ! false, currentDate.AddDays(-this.numDaysForOptimizationPeriod), ! currentDate, this.numberOfEligibleTickers, this.benchmark); ! return quotedAtEachMarketDayFromEligible.GetTableOfSelectedTickers(); ! } ! ! private void setTickers_setChosenTickers_addGenomeForOptimizationOutput(Genome genome, DateTime currentDate) ! { ! this.optimizationOutput.Add(new GenomeRepresentation(this.maxNumOfStdDevForNormalGap, ! genome, ! currentDate.AddDays(-this.numDaysForOptimizationPeriod), ! currentDate)); ! } ! private void setTickers_setChosenTickers_addTickers(Genome genome) ! { ! this.chosenTickers[this.addedTickersCounter] = ! ((GenomeMeaningSimplePT)genome.Meaning).FirstTicker; ! this.chosenTickers[this.addedTickersCounter+1] = ! ((GenomeMeaningSimplePT)genome.Meaning).SecondTicker; ! ! this.averageGapsOfChosenTickers[this.addedTickersCounter] = ! ((GenomeMeaningSimplePT)genome.Meaning).AverageGap; ! this.stdDevGapsOfChosenTickers[this.addedTickersCounter] = ! ((GenomeMeaningSimplePT)genome.Meaning).StdDevGap; ! this.currentNumDaysForGapComputation = ((GenomeMeaningSimplePT)genome.Meaning).NumOfDaysForGap; ! ! this.addedTickersCounter += 2; ! } ! ! private bool setTickers_setChosenTickers_isAnyTickerOfGenomeInChosenTickers(Genome genome) ! { ! bool returnValue = false; ! foreach(string ticker in this.chosenTickers) ! { ! if(ticker == ((GenomeMeaningSimplePT)genome.Meaning).FirstTicker || ! ticker == ((GenomeMeaningSimplePT)genome.Meaning).SecondTicker) ! returnValue = true; ! } ! return returnValue; ! } ! ! private void setTickers_setChosenTickers(GeneticOptimizer GO, DateTime currentDate) ! { ! this.addedTickersCounter = 0; ! for(int i = 0; ! i<GO.CurrentGeneration.Count -1 && ! addedTickersCounter<this.chosenTickers.Length; ! i++) ! { ! Genome currentGenome = (Genome)GO.CurrentGeneration[GO.CurrentGeneration.Count-i-1]; ! if(!this.setTickers_setChosenTickers_isAnyTickerOfGenomeInChosenTickers(currentGenome)) ! { ! this.setTickers_setChosenTickers_addTickers(currentGenome); ! this.setTickers_setChosenTickers_addGenomeForOptimizationOutput(currentGenome, ! currentDate); ! } ! } ! } ! private void setTickers(DateTime currentDate) ! { ! ! DataTable setOfTickersToBeOptimized = this.getSetOfTickersToBeOptimized(currentDate); ! IGenomeManager genManForSimplePT = ! new GenomeManagerForSimplePT(setOfTickersToBeOptimized, ! currentDate.AddDays(-this.numDaysForOptimizationPeriod), ! currentDate, ! this.minNumOfDaysForGapComputation, ! this.maxNumOfDaysForGapComputation, ! this.maxNumOfStdDevForNormalGap); ! ! GeneticOptimizer GO = new GeneticOptimizer(genManForSimplePT, ! this.populationSizeForGeneticOptimizer, ! this.generationNumberForGeneticOptimizer, ! this.seedForRandomGenerator); ! GO.Run(false); ! this.setTickers_setChosenTickers(GO, currentDate); ! } ! /// <summary> ! /// Handles a "One hour after market close" event. ! /// </summary> ! /// <param name="sender"></param> ! /// <param name="eventArgs"></param> ! protected override void oneHourAfterMarketCloseEventHandler( ! Object sender , DateTime dateTime ) ! { ! this.seedForRandomGenerator++; ! if(this.numDaysElapsedSinceLastOptimization == ! this.numDaysBetweenEachOptimization - 1) ! { ! this.setTickers( dateTime ); ! //sets tickers to be chosen at next Market Open event ! this.numDaysElapsedSinceLastOptimization = 0; ! } ! else ! { ! this.numDaysElapsedSinceLastOptimization++; ! } ! } ! #endregion ! ! } } Index: RunSimplePairTrading.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/ArbitrageTesting/PairTrading/SimplePairTrading/RunSimplePairTrading.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** RunSimplePairTrading.cs 19 Aug 2008 17:13:09 -0000 1.2 --- RunSimplePairTrading.cs 29 Sep 2008 21:16:41 -0000 1.3 *************** *** 3,7 **** RunSimplePairTrading.cs ! Copyright (C) 2003 Marco Milletti --- 3,7 ---- RunSimplePairTrading.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,147 **** { ! /// <summary> /// Script to test the pair trading strategy on two single tickers /// </summary> ! [Serializable] ! public class RunSimplePairTrading : RunPairTrading ! { ! private EndOfDayTimerHandlerSimplePT endOfDayTimerHandler; ! public RunSimplePairTrading(string tickerGroupID, int numberOfEligibleTickers, ! int numDaysForOptimizationPeriod, ! int generationNumberForGeneticOptimizer, ! int populationSizeForGeneticOptimizer, string benchmark, ! DateTime startDate, DateTime endDate, ! double maxNumOfStdDevForNormalGap, int minNumOfDaysForGapComputation, ! int maxNumOfDaysForGapComputation, int numDaysBetweenEachOptimization, ! double maxRunningHours): ! base(tickerGroupID, numberOfEligibleTickers, ! numDaysForOptimizationPeriod, ! generationNumberForGeneticOptimizer, ! populationSizeForGeneticOptimizer, benchmark, ! startDate, endDate, ! minNumOfDaysForGapComputation, maxNumOfDaysForGapComputation, ! maxNumOfStdDevForNormalGap, numDaysBetweenEachOptimization, ! maxRunningHours) ! { ! } ! ! #region auxiliary overriden methods for Run ! ! ! ! protected override void run_initializeEndOfDayTimerHandler() ! { ! this.endOfDayTimerHandler = new EndOfDayTimerHandlerSimplePT(this.tickerGroupID, ! this.numberOfEligibleTickers, ! this.numDaysForOptimizationPeriod, ! this.generationNumberForGeneticOptimizer, ! this.populationSizeForGeneticOptimizer, ! this.benchmark, this.startDateTime.DateTime, this.endDateTime.DateTime, ! this.maxNumOfStdDevForNormalGap, this.minNumOfDaysForGapComputation, ! this.maxNumOfDaysForGapComputation, ! this.numDaysBetweenEachOptimization, this.maxRunningHours, this.account); ! } ! ! ! 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 RunPairTrading.Run() ! //in classes that inherit from this class ! public override void Run() ! { ! base.Run(); ! } ! public override void SaveScriptResults() ! { ! string fileName = "From"+this.numberOfEligibleTickers + ! "OptDays" + this.numDaysForOptimizationPeriod + "GenNum" + ! this.generationNumberForGeneticOptimizer + ! "PopSize" + this.populationSizeForGeneticOptimizer; ! string dirNameWhereToSaveAccounts = ! System.Configuration.ConfigurationManager.AppSettings["AccountsArchive"] + ! "\\" + this.ScriptName + "\\"; ! string dirNameWhereToSaveTransactions = ! System.Configuration.ConfigurationManager.AppSettings["TransactionsArchive"] + ! "\\" + this.ScriptName + "\\"; ! // string dirNameWhereToSaveBestGenomes = System.Configuration.ConfigurationSettings.AppSettings["GenomesArchive"] + ! // "\\" + this.ScriptName + "\\"; ! ! this.checkDateForReport_createDirIfNotPresent(dirNameWhereToSaveAccounts); ! this.checkDateForReport_createDirIfNotPresent(dirNameWhereToSaveTransactions); ! // this.checkDateForReport_createDirIfNotPresent(dirNameWhereToSaveBestGenomes); ! ! ObjectArchiver.Archive(this.account, ! dirNameWhereToSaveAccounts + ! fileName + ".qPa"); ! ObjectArchiver.Archive(this.account.Transactions, ! dirNameWhereToSaveTransactions + ! fileName + ".qPt"); ! ! // OptimizationOutput optimizationOutput = new OptimizationOutput(); ! // foreach(GenomeRepresentation genomeRepresentation in this.endOfDayTimerHandler.BestGenomes) ! // optimizationOutput.Add(genomeRepresentation); ! // ObjectArchiver.Archive(optimizationOutput, ! // dirNameWhereToSaveBestGenomes + ! // fileName + ".bgn"); ! this.endOfDayTimer.Stop(); ! new OutputDisplayer(this.startDateTime.DateTime, this.endDateTime.DateTime, ! this.endOfDayTimerHandler.OptimizationOutput).Show(); ! ! } } } --- 36,152 ---- { ! /// <summary> /// Script to test the pair trading strategy on two single tickers /// </summary> ! [Serializable] ! public class RunSimplePairTrading : RunPairTrading ! { ! private EndOfDayTimerHandlerSimplePT endOfDayTimerHandler; ! public RunSimplePairTrading(string tickerGroupID, int numberOfEligibleTickers, ! int numDaysForOptimizationPeriod, ! int generationNumberForGeneticOptimizer, ! int populationSizeForGeneticOptimizer, string benchmark, ! DateTime startDate, DateTime endDate, ! double maxNumOfStdDevForNormalGap, int minNumOfDaysForGapComputation, ! int maxNumOfDaysForGapComputation, int numDaysBetweenEachOptimization, ! double maxRunningHours): ! base(tickerGroupID, numberOfEligibleTickers, ! numDaysForOptimizationPeriod, ! generationNumberForGeneticOptimizer, ! populationSizeForGeneticOptimizer, benchmark, ! startDate, endDate, ! minNumOfDaysForGapComputation, maxNumOfDaysForGapComputation, ! maxNumOfStdDevForNormalGap, numDaysBetweenEachOptimization, ! maxRunningHours) ! { ! } ! ! #region auxiliary overriden methods for Run ! ! ! ! protected override void run_initializeEndOfDayTimerHandler() ! { ! this.endOfDayTimerHandler = new EndOfDayTimerHandlerSimplePT(this.tickerGroupID, ! this.numberOfEligibleTickers, ! this.numDaysForOptimizationPeriod, ! this.generationNumberForGeneticOptimizer, ! this.populationSizeForGeneticOptimizer, ! this.benchmark, this.startDateTime, this.endDateTime, ! this.maxNumOfStdDevForNormalGap, this.minNumOfDaysForGapComputation, ! this.maxNumOfDaysForGapComputation, ! this.numDaysBetweenEachOptimization, this.maxRunningHours, this.account); ! } ! ! ! protected override void run_addEventHandlers() ! { ! this.timer.NewDateTime += ! new NewDateTimeEventHandler( this.endOfDayTimerHandler.NewDateTimeEventHandler ); ! this.timer.NewDateTime += ! new NewDateTimeEventHandler( this.checkDateForReport ); ! ! // this.timer.MarketOpen += ! // new MarketOpenEventHandler( ! // this.endOfDayTimerHandler.MarketOpenEventHandler); ! // ! // this.timer.MarketClose += ! // new MarketCloseEventHandler( ! // this.endOfDayTimerHandler.MarketCloseEventHandler); ! // ! // this.timer.MarketClose += ! // new MarketCloseEventHandler( ! // this.checkDateForReport); ! // ! // this.timer.OneHourAfterMarketClose += ! // new OneHourAfterMarketCloseEventHandler( ! // this.endOfDayTimerHandler.OneHourAfterMarketCloseEventHandler ); ! } ! #endregion ! ! //necessary far calling RunPairTrading.Run() ! //in classes that inherit from this class ! public override void Run() ! { ! base.Run(); ! } ! public override void SaveScriptResults() ! { ! string fileName = "From"+this.numberOfEligibleTickers + ! "OptDays" + this.numDaysForOptimizationPeriod + "GenNum" + ! this.generationNumberForGeneticOptimizer + ! "PopSize" + this.populationSizeForGeneticOptimizer; ! string dirNameWhereToSaveAccounts = ! System.Configuration.ConfigurationManager.AppSettings["AccountsArchive"] + ! "\\" + this.ScriptName + "\\"; ! string dirNameWhereToSaveTransactions = ! System.Configuration.ConfigurationManager.AppSettings["TransactionsArchive"] + ! "\\" + this.ScriptName + "\\"; ! // string dirNameWhereToSaveBestGenomes = System.Configuration.ConfigurationSettings.AppSettings["GenomesArchive"] + ! // "\\" + this.ScriptName + "\\"; ! ! this.checkDateForReport_createDirIfNotPresent(dirNameWhereToSaveAccounts); ! this.checkDateForReport_createDirIfNotPresent(dirNameWhereToSaveTransactions); ! // this.checkDateForReport_createDirIfNotPresent(dirNameWhereToSaveBestGenomes); ! ! ObjectArchiver.Archive(this.account, ! dirNameWhereToSaveAccounts + ! fileName + ".qPa"); ! ObjectArchiver.Archive(this.account.Transactions, ! dirNameWhereToSaveTransactions + ! fileName + ".qPt"); ! ! // OptimizationOutput optimizationOutput = new OptimizationOutput(); ! // foreach(GenomeRepresentation genomeRepresentation in this.endOfDayTimerHandler.BestGenomes) ! // optimizationOutput.Add(genomeRepresentation); ! // ObjectArchiver.Archive(optimizationOutput, ! // dirNameWhereToSaveBestGenomes + ! // fileName + ".bgn"); ! this.timer.Stop(); ! new OutputDisplayer(this.startDateTime, this.endDateTime, ! this.endOfDayTimerHandler.OptimizationOutput).Show(); ! ! } } } |
|
From: Glauco S. <gla...@us...> - 2008-09-29 21:17:27
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/General/Strategies In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv15598/Strategies Modified Files: SimpleStrategy.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: SimpleStrategy.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/General/Strategies/SimpleStrategy.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** SimpleStrategy.cs 16 Aug 2008 19:06:12 -0000 1.1 --- SimpleStrategy.cs 29 Sep 2008 21:17:04 -0000 1.2 *************** *** 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; *************** *** 44,52 **** WeightedPositions weightedPositions , IIntervalsSelector intervalsSelector , ! IHistoricalQuoteProvider historicalQuoteProvider ) : base( 999 , 1 , intervalsSelector , intervalsSelector , ! new DummyEligibleSelector() , ! new DummyInSampleChooser() , ! historicalQuoteProvider ) { this.weightedPositions = weightedPositions; --- 44,52 ---- WeightedPositions weightedPositions , IIntervalsSelector intervalsSelector , ! HistoricalMarketValueProvider historicalMarketValueProvider ) : base( 999 , 1 , intervalsSelector , intervalsSelector , ! new DummyEligibleSelector() , ! new DummyInSampleChooser() , ! historicalMarketValueProvider ) { this.weightedPositions = weightedPositions; *************** *** 57,67 **** // true iif the current EndOfDayDateTime falls on the end of either the last // interval or the second last interval ! bool arePositionsToBeClosed = ( ( this.Account.Portfolio.Count > 0 ) && ! ( this.returnIntervals[ this.returnIntervals.Count - 1 ].End.IsEqualTo( ! this.now() ) ! || ! ( ( this.returnIntervals.Count > 1 ) && ! ( this.returnIntervals[ this.returnIntervals.Count - 2 ].End.IsEqualTo( ! this.now() ) ) ) ) ); return arePositionsToBeClosed; } --- 57,68 ---- // true iif the current EndOfDayDateTime falls on the end of either the last // interval or the second last interval ! bool arePositionsToBeClosed = ! ( ( this.Account.Portfolio.Count > 0 ) && ! ( ( this.returnIntervals[ this.returnIntervals.Count - 1 ].End == ! this.now() ) ! || ! ( ( this.returnIntervals.Count > 1 ) && ! ( this.returnIntervals[ this.returnIntervals.Count - 2 ].End == ! this.now() ) ) ) ); return arePositionsToBeClosed; } *************** *** 76,81 **** bool arePositionsToBeOpened = ( ( this.Account.Portfolio.Count == 0 ) && ! this.returnIntervals[ this.returnIntervals.Count - 1 ].Begin.IsEqualTo( ! this.now() ) ); return arePositionsToBeOpened; } --- 77,82 ---- bool arePositionsToBeOpened = ( ( this.Account.Portfolio.Count == 0 ) && ! this.returnIntervals[ this.returnIntervals.Count - 1 ].Begin == ! this.now() ); return arePositionsToBeOpened; } |
|
From: Glauco S. <gla...@us...> - 2008-09-29 21:17:23
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/General/Logging In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv15598/Logging Modified Files: DummyTesterForTestingPositions.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: DummyTesterForTestingPositions.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/General/Logging/DummyTesterForTestingPositions.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** DummyTesterForTestingPositions.cs 8 Apr 2008 21:34:31 -0000 1.1 --- DummyTesterForTestingPositions.cs 29 Sep 2008 21:17:03 -0000 1.2 *************** *** 42,46 **** private TestingPositions testingPositions; private int numberOfInSampleDays; ! private EndOfDayDateTime endOfDayDateTimeWhenThisObjectWasLogged; /// <summary> --- 42,46 ---- private TestingPositions testingPositions; private int numberOfInSampleDays; ! private DateTime dateTimeWhenThisObjectWasLogged; /// <summary> *************** *** 70,79 **** TestingPositions testingPositions , int numberOfInSampleDays , ! EndOfDayDateTime endOfDayDateTimeWhenThisObjectWasLogged ) { this.testingPositions = testingPositions; this.numberOfInSampleDays = numberOfInSampleDays; ! this.endOfDayDateTimeWhenThisObjectWasLogged = ! endOfDayDateTimeWhenThisObjectWasLogged; } --- 70,79 ---- TestingPositions testingPositions , int numberOfInSampleDays , ! DateTime dateTimeWhenThisObjectWasLogged ) { this.testingPositions = testingPositions; this.numberOfInSampleDays = numberOfInSampleDays; ! this.dateTimeWhenThisObjectWasLogged = ! dateTimeWhenThisObjectWasLogged; } |
|
From: Glauco S. <gla...@us...> - 2008-09-29 21:17:22
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/General In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv15598 Modified Files: BasicScriptForBacktesting.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: BasicScriptForBacktesting.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/General/BasicScriptForBacktesting.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** BasicScriptForBacktesting.cs 13 Apr 2008 16:27:20 -0000 1.3 --- BasicScriptForBacktesting.cs 29 Sep 2008 21:17:03 -0000 1.4 *************** *** 48,52 **** protected IEligiblesSelector eligiblesSelector; protected IInSampleChooser inSampleChooser; ! protected IEndOfDayStrategyForBacktester endOfDayStrategy; protected EndOfDayStrategyBackTester endOfDayStrategyBackTester; --- 48,52 ---- protected IEligiblesSelector eligiblesSelector; protected IInSampleChooser inSampleChooser; ! protected IStrategyForBacktester strategyForBacktester; protected EndOfDayStrategyBackTester endOfDayStrategyBackTester; *************** *** 102,106 **** protected abstract IInSampleChooser getInSampleChooser(); ! protected abstract IEndOfDayStrategyForBacktester getEndOfDayStrategy(); protected abstract EndOfDayStrategyBackTester getEndOfDayStrategyBackTester(); --- 102,106 ---- protected abstract IInSampleChooser getInSampleChooser(); ! protected abstract IStrategyForBacktester getStrategyForBacktester(); protected abstract EndOfDayStrategyBackTester getEndOfDayStrategyBackTester(); *************** *** 189,193 **** this.eligiblesSelector = this.getEligiblesSelector(); this.inSampleChooser = this.getInSampleChooser(); ! this.endOfDayStrategy = this.getEndOfDayStrategy(); this.endOfDayStrategyBackTester = this.getEndOfDayStrategyBackTester(); } --- 189,193 ---- this.eligiblesSelector = this.getEligiblesSelector(); this.inSampleChooser = this.getInSampleChooser(); ! this.strategyForBacktester = this.getStrategyForBacktester(); this.endOfDayStrategyBackTester = this.getEndOfDayStrategyBackTester(); } *************** *** 216,220 **** this.messageManager.Monitor( this.eligiblesSelector ); this.messageManager.Monitor( this.inSampleChooser ); ! this.messageManager.Monitor( this.endOfDayStrategy ); this.messageManager.Monitor( this.endOfDayStrategyBackTester ); } --- 216,220 ---- this.messageManager.Monitor( this.eligiblesSelector ); this.messageManager.Monitor( this.inSampleChooser ); ! this.messageManager.Monitor( this.strategyForBacktester ); this.messageManager.Monitor( this.endOfDayStrategyBackTester ); } |
|
From: Glauco S. <gla...@us...> - 2008-09-29 21:17:17
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/ArbitrageTesting/PairTrading/SimplePairTrading/InSample In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv15453/PairTrading/SimplePairTrading/InSample Modified Files: EndOfDayTimerHandlerSimplePTIS.cs RunSimplePairTradingIS.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: EndOfDayTimerHandlerSimplePTIS.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/ArbitrageTesting/PairTrading/SimplePairTrading/InSample/EndOfDayTimerHandlerSimplePTIS.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** EndOfDayTimerHandlerSimplePTIS.cs 14 May 2006 15:25:30 -0000 1.1 --- EndOfDayTimerHandlerSimplePTIS.cs 29 Sep 2008 21:16:41 -0000 1.2 *************** *** 94,105 **** /// <param name="sender"></param> /// <param name="eventArgs"></param> ! public override void MarketCloseEventHandler( ! Object sender , EndOfDayTimingEventArgs endOfDayTimingEventArgs ) { if(((IndexBasedEndOfDayTimer)sender).GetPreviousDateTime() != ! endOfDayTimingEventArgs.EndOfDayDateTime.DateTime) //it is not the first date fired by the timer, so the // gap can be computed ! base.MarketCloseEventHandler(sender, endOfDayTimingEventArgs); } --- 94,105 ---- /// <param name="sender"></param> /// <param name="eventArgs"></param> ! protected override void marketCloseEventHandler( ! Object sender , DateTime dateTime ) { if(((IndexBasedEndOfDayTimer)sender).GetPreviousDateTime() != ! dateTime) //it is not the first date fired by the timer, so the // gap can be computed ! base.marketCloseEventHandler(sender, dateTime); } *************** *** 109,114 **** /// <param name="sender"></param> /// <param name="eventArgs"></param> ! public override void OneHourAfterMarketCloseEventHandler( ! Object sender , EndOfDayTimingEventArgs endOfDayTimingEventArgs ) { --- 109,114 ---- /// <param name="sender"></param> /// <param name="eventArgs"></param> ! protected override void oneHourAfterMarketCloseEventHandler( ! Object sender , DateTime dateTime ) { Index: RunSimplePairTradingIS.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/ArbitrageTesting/PairTrading/SimplePairTrading/InSample/RunSimplePairTradingIS.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** RunSimplePairTradingIS.cs 14 May 2006 15:25:30 -0000 1.1 --- RunSimplePairTradingIS.cs 29 Sep 2008 21:16:41 -0000 1.2 *************** *** 3,7 **** RunSimplePairTradingIS.cs ! Copyright (C) 2003 Marco Milletti --- 3,7 ---- RunSimplePairTradingIS.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,180 **** { ! /// <summary> /// Script to test the pair trading strategy for /// two tickers for a given time period /// </summary> ! [Serializable] ! public class RunSimplePairTradingIS ! { ! private double maxNumOfStdDevForNormalGap; ! private int numDaysForGap; ! private double averageGap; ! private double stdDevGap; ! private EndOfDayTimerHandlerSimplePT endOfDayTimerHandler; ! private string firstTicker; ! private string secondTicker; ! private DateTime startDateTime; ! private DateTime endDateTime; ! private IHistoricalQuoteProvider historicalQuoteProvider; ! private Account account; ! private IEndOfDayTimer endOfDayTimer; ! private string benchmark; ! private string scriptName; ! public RunSimplePairTradingIS(double maxNumOfStdDevForNormalGap, ! int numDaysForGap, ! double averageGap, ! double stdDevGap, ! string firstTicker, string secondTicker, ! DateTime startDate, DateTime endDate) ! ! { ! this.maxNumOfStdDevForNormalGap = maxNumOfStdDevForNormalGap; ! this.numDaysForGap = numDaysForGap; ! this.averageGap = averageGap; ! this.stdDevGap = stdDevGap; ! this.firstTicker = firstTicker; ! this.secondTicker = secondTicker; ! this.startDateTime = startDate; ! this.endDateTime = endDate; ! this.benchmark = "^GSPC"; ! this.scriptName = "SimplePairTradingForGivenTickers"; ! } ! ! #region Run ! ! private void run_initializeEndOfDayTimer() ! { ! //default endOfDayTimer ! this.endOfDayTimer = ! new IndexBasedEndOfDayTimer( new EndOfDayDateTime(this.startDateTime, ! EndOfDaySpecificTime.MarketOpen), ! this.benchmark ); ! ! } ! ! protected void run_initializeAccount() ! { ! //default account with no commissions and no slippage calculation ! this.account = new Account( this.scriptName , this.endOfDayTimer , ! new HistoricalEndOfDayDataStreamer( this.endOfDayTimer , ! this.historicalQuoteProvider ) , ! new HistoricalEndOfDayOrderExecutor( this.endOfDayTimer , ! this.historicalQuoteProvider )); ! ! } ! ! private void run_initializeHistoricalQuoteProvider() ! { ! this.historicalQuoteProvider = new HistoricalAdjustedQuoteProvider(); ! } ! ! ! private void checkDateForReport(Object sender , EndOfDayTimingEventArgs endOfDayTimingEventArgs) ! { ! if(endOfDayTimingEventArgs.EndOfDayDateTime.DateTime>=this.endDateTime) ! //last date is reached by the timer ! this.showReport(); ! } ! ! private void showReport() ! { ! AccountReport accountReport = this.account.CreateReport(this.scriptName, 1, ! this.endOfDayTimer.GetCurrentTime(), ! this.benchmark, ! new HistoricalAdjustedQuoteProvider()); ! Report report = new Report(accountReport); ! report.Show(); ! this.endOfDayTimer.Stop(); ! ! } ! ! private void run_initialize() ! { ! run_initializeHistoricalQuoteProvider(); ! run_initializeEndOfDayTimer(); ! run_initializeAccount(); ! run_initializeEndOfDayTimerHandler(); ! } ! ! ! public void Run() ! { ! this.run_initialize(); ! this.run_addEventHandlers(); ! this.endOfDayTimer.Start(); ! } ! ! private void run_initializeEndOfDayTimerHandler() ! { ! this.endOfDayTimerHandler = new EndOfDayTimerHandlerSimplePTIS(this.maxNumOfStdDevForNormalGap, ! this.numDaysForGap, ! this.averageGap, ! this.stdDevGap, ! this.firstTicker, this.secondTicker, ! this.startDateTime, this.endDateTime, ! this.account); ! } ! ! ! private 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 ! } } --- 39,187 ---- { ! /// <summary> /// Script to test the pair trading strategy for /// two tickers for a given time period /// </summary> ! [Serializable] ! public class RunSimplePairTradingIS ! { ! private double maxNumOfStdDevForNormalGap; ! private int numDaysForGap; ! private double averageGap; ! private double stdDevGap; ! private EndOfDayTimerHandlerSimplePT endOfDayTimerHandler; ! private string firstTicker; ! private string secondTicker; ! private DateTime startDateTime; ! private DateTime endDateTime; ! private HistoricalMarketValueProvider historicalMarketValueProvider; ! private Account account; ! private Timer timer; ! private string benchmark; ! private string scriptName; ! public RunSimplePairTradingIS(double maxNumOfStdDevForNormalGap, ! int numDaysForGap, ! double averageGap, ! double stdDevGap, ! string firstTicker, string secondTicker, ! DateTime startDate, DateTime endDate) ! ! { ! this.maxNumOfStdDevForNormalGap = maxNumOfStdDevForNormalGap; ! this.numDaysForGap = numDaysForGap; ! this.averageGap = averageGap; ! this.stdDevGap = stdDevGap; ! this.firstTicker = firstTicker; ! this.secondTicker = secondTicker; ! this.startDateTime = startDate; ! this.endDateTime = endDate; ! this.benchmark = "^GSPC"; ! this.scriptName = "SimplePairTradingForGivenTickers"; ! } ! ! #region Run ! ! private void run_initializeEndOfDayTimer() ! { ! //default endOfDayTimer ! this.timer = ! new IndexBasedEndOfDayTimer( ! HistoricalEndOfDayTimer.GetMarketOpen( this.startDateTime ) , ! // new EndOfDayDateTime(this.startDateTime, ! // EndOfDaySpecificTime.MarketOpen), ! this.benchmark ); ! ! } ! ! protected void run_initializeAccount() ! { ! //default account with no commissions and no slippage calculation ! this.account = new Account( this.scriptName , this.timer , ! new HistoricalEndOfDayDataStreamer( this.timer , ! this.historicalMarketValueProvider ) , ! new HistoricalEndOfDayOrderExecutor( this.timer , ! this.historicalMarketValueProvider )); ! ! } ! ! private void run_initializeHistoricalQuoteProvider() ! { ! this.historicalMarketValueProvider = new HistoricalAdjustedQuoteProvider(); ! } ! ! ! private void checkDateForReport( Object sender , DateTime dateTime ) ! { ! if(dateTime>=this.endDateTime) ! //last date is reached by the timer ! this.showReport(); ! } ! ! private void showReport() ! { ! AccountReport accountReport = this.account.CreateReport(this.scriptName, 1, ! this.timer.GetCurrentDateTime(), ! this.benchmark, ! new HistoricalAdjustedQuoteProvider()); ! Report report = new Report(accountReport); ! report.Show(); ! this.timer.Stop(); ! ! } ! ! private void run_initialize() ! { ! run_initializeHistoricalQuoteProvider(); ! run_initializeEndOfDayTimer(); ! run_initializeAccount(); ! run_initializeEndOfDayTimerHandler(); ! } ! ! ! public void Run() ! { ! this.run_initialize(); ! this.run_addEventHandlers(); ! this.timer.Start(); ! } ! ! private void run_initializeEndOfDayTimerHandler() ! { ! this.endOfDayTimerHandler = new EndOfDayTimerHandlerSimplePTIS(this.maxNumOfStdDevForNormalGap, ! this.numDaysForGap, ! this.averageGap, ! this.stdDevGap, ! this.firstTicker, this.secondTicker, ! this.startDateTime, this.endDateTime, ! this.account); ! } ! ! ! private void run_addEventHandlers() ! { ! this.timer.NewDateTime += ! new NewDateTimeEventHandler( this.endOfDayTimerHandler.NewDateTimeEventHandler ); ! this.timer.NewDateTime += ! new NewDateTimeEventHandler( this.checkDateForReport ); ! ! // this.timer.MarketOpen += ! // new MarketOpenEventHandler( ! // this.endOfDayTimerHandler.MarketOpenEventHandler); ! // ! // this.timer.MarketClose += ! // new MarketCloseEventHandler( ! // this.endOfDayTimerHandler.MarketCloseEventHandler); ! // ! // this.timer.MarketClose += ! // new MarketCloseEventHandler( ! // this.checkDateForReport); ! // ! // this.timer.OneHourAfterMarketClose += ! // new OneHourAfterMarketCloseEventHandler( ! // this.endOfDayTimerHandler.OneHourAfterMarketCloseEventHandler ); ! } ! #endregion ! } } |
|
From: Glauco S. <gla...@us...> - 2008-09-29 21:17:16
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/ArbitrageTesting/OverReactionHypothesis/DoubleOverReaction_WeekEndBounce In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv15453/OverReactionHypothesis/DoubleOverReaction_WeekEndBounce Modified Files: RunDOR_WeekEndBounce.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: RunDOR_WeekEndBounce.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/ArbitrageTesting/OverReactionHypothesis/DoubleOverReaction_WeekEndBounce/RunDOR_WeekEndBounce.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** RunDOR_WeekEndBounce.cs 19 Aug 2008 17:13:04 -0000 1.2 --- RunDOR_WeekEndBounce.cs 29 Sep 2008 21:16:40 -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; --- 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; *************** *** 37,170 **** /// Script that implements the Double OverReaction Week End Bounce strategy: /// at each Monday open, l long positions and s short positions will be open, ! /// buying and shorting, accordingly, the l tickers among the /// b best that more moves down (at open) and the s tickers among the w worst /// that more moves up (at open). ! /// For chosing the b best and w worst tickers the /// given previous lengthInDays Performance is considered. ! /// The fundamental of the strategy should be the fact (to be verified ...) /// that overreactions may be followed by opposite overreactions. /// At each wednesday open, positions are closed. /// </summary> ! [Serializable] ! public class RunDOR_WeekEndBounce ! { ! private string scriptName; ! private string tickerGroupID; ! private string benchmark; ! private int numberOfEligibleTickers; ! private int numOfBestTickers; ! private int numOfWorstTickers; private int lengthInDaysForPerformance; ! private int numOfTickersForBuying; ! private int numOfTickersForShortSelling; ! private DateTime startDate; ! private DateTime endDate; ! private double maxRunningHours; ! private DateTime startingTimeForScript; ! private Account account; ! private IHistoricalQuoteProvider historicalQuoteProvider; ! private IEndOfDayTimer endOfDayTimer; ! public RunDOR_WeekEndBounce(string tickerGroupID, string benchmark, ! int numberOfEligibleTickers, int numOfBestTickers, ! int numOfWorstTickers, int numOfTickersForBuying, ! int numOfTickersForShortSelling, ! DateTime startDate, DateTime endDate, int lengthInDaysForPerformance, ! double maxRunningHours) ! { ! this.tickerGroupID = tickerGroupID; ! this.benchmark = benchmark; ! this.numberOfEligibleTickers = numberOfEligibleTickers; ! this.numOfBestTickers = numOfBestTickers; ! this.numOfWorstTickers = numOfWorstTickers; ! this.numOfTickersForBuying = numOfTickersForBuying; ! this.numOfTickersForShortSelling = numOfTickersForShortSelling; ! this.startDate = startDate; ! this.endDate = endDate; ! this.maxRunningHours = maxRunningHours; ! this.scriptName = "DoubleOverReaction_WeekEndBounce"; ! this.historicalQuoteProvider = new HistoricalAdjustedQuoteProvider(); ! this.endOfDayTimer = new IndexBasedEndOfDayTimer( ! new EndOfDayDateTime( this.startDate , ! EndOfDaySpecificTime.MarketOpen ) , this.benchmark ); this.lengthInDaysForPerformance = lengthInDaysForPerformance; ! } ! public void Run() ! { ! this.startingTimeForScript = DateTime.Now; ! this.account = new Account( "WeekEndBounce" , this.endOfDayTimer , ! new HistoricalEndOfDayDataStreamer( this.endOfDayTimer , ! this.historicalQuoteProvider ) , ! new HistoricalEndOfDayOrderExecutor( this.endOfDayTimer , ! this.historicalQuoteProvider ) ); ! EndOfDayTimerHandlerDOR_WeekEndBounce endOfDayTimerHandler = ! new EndOfDayTimerHandlerDOR_WeekEndBounce(this.tickerGroupID, this.numberOfEligibleTickers, ! this.numOfBestTickers, this.numOfWorstTickers, this.lengthInDaysForPerformance, ! this.numOfTickersForBuying, this.numOfTickersForShortSelling, ! this.account, this.benchmark); ! this.endOfDayTimer.MarketOpen += new MarketOpenEventHandler( ! endOfDayTimerHandler.MarketOpenEventHandler ); ! ! this.endOfDayTimer.MarketClose += new MarketCloseEventHandler( ! endOfDayTimerHandler.MarketCloseEventHandler ); ! this.endOfDayTimer.MarketClose += new MarketCloseEventHandler( ! this.checkDateForReport); ! this.endOfDayTimer.OneHourAfterMarketClose += new OneHourAfterMarketCloseEventHandler( ! endOfDayTimerHandler.OneHourAfterMarketCloseEventHandler ); ! ! this.endOfDayTimer.Start(); ! } ! private void checkDateForReport(Object sender , EndOfDayTimingEventArgs endOfDayTimingEventArgs) ! { ! if(endOfDayTimingEventArgs.EndOfDayDateTime.DateTime>=this.endDate || ! 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.SaveScriptResults(); ! } ! private void checkDateForReport_createDirIfNotPresent(string dirPath) ! { ! if(!Directory.Exists(dirPath)) ! Directory.CreateDirectory(dirPath); ! } ! public void SaveScriptResults() ! { ! TimeSpan span; span = DateTime.Now.Subtract(this.startingTimeForScript); int secondsElapsed = span.Hours * 3600 + span.Minutes * 60 + span.Seconds; ! string fileName = ! "SecondsElapsed_" + secondsElapsed.ToString() + "_" + ! DateTime.Now.Hour.ToString().PadLeft(2,'0') + "_" + ! DateTime.Now.Minute.ToString().PadLeft(2,'0') + "_" + ! this.scriptName + "_From_" + this.tickerGroupID + ! "_elig_" + this.numberOfEligibleTickers + ! "_best_" + this.numOfBestTickers + ! "_worst_" + this.numOfWorstTickers + ! "_forLong_" + this.numOfTickersForBuying + ! "_forShort_" + this.numOfTickersForShortSelling; ! string dirNameWhereToSaveReports = ! System.Configuration.ConfigurationManager.AppSettings["ReportsArchive"] + ! "\\" + this.scriptName + "\\"; ! ! //default report with numIntervalDays = 1 ! AccountReport accountReport = this.account.CreateReport( fileName,1, ! this.endOfDayTimer.GetCurrentTime(), ! this.benchmark, ! new HistoricalAdjustedQuoteProvider() ); ! this.checkDateForReport_createDirIfNotPresent(dirNameWhereToSaveReports); ! ObjectArchiver.Archive(accountReport, ! dirNameWhereToSaveReports + ! fileName + ".qPr"); ! ! this.endOfDayTimer.Stop(); ! } ! } } --- 37,178 ---- /// Script that implements the Double OverReaction Week End Bounce strategy: /// at each Monday open, l long positions and s short positions will be open, ! /// buying and shorting, accordingly, the l tickers among the /// b best that more moves down (at open) and the s tickers among the w worst /// that more moves up (at open). ! /// For chosing the b best and w worst tickers the /// given previous lengthInDays Performance is considered. ! /// The fundamental of the strategy should be the fact (to be verified ...) /// that overreactions may be followed by opposite overreactions. /// At each wednesday open, positions are closed. /// </summary> ! [Serializable] ! public class RunDOR_WeekEndBounce ! { ! private string scriptName; ! private string tickerGroupID; ! private string benchmark; ! private int numberOfEligibleTickers; ! private int numOfBestTickers; ! private int numOfWorstTickers; private int lengthInDaysForPerformance; ! private int numOfTickersForBuying; ! private int numOfTickersForShortSelling; ! private DateTime startDate; ! private DateTime endDate; ! private double maxRunningHours; ! private DateTime startingTimeForScript; ! private Account account; ! private HistoricalMarketValueProvider historicalMarketValueProvider; ! private Timer timer; ! public RunDOR_WeekEndBounce(string tickerGroupID, string benchmark, ! int numberOfEligibleTickers, int numOfBestTickers, ! int numOfWorstTickers, int numOfTickersForBuying, ! int numOfTickersForShortSelling, ! DateTime startDate, DateTime endDate, int lengthInDaysForPerformance, ! double maxRunningHours) ! { ! this.tickerGroupID = tickerGroupID; ! this.benchmark = benchmark; ! this.numberOfEligibleTickers = numberOfEligibleTickers; ! this.numOfBestTickers = numOfBestTickers; ! this.numOfWorstTickers = numOfWorstTickers; ! this.numOfTickersForBuying = numOfTickersForBuying; ! this.numOfTickersForShortSelling = numOfTickersForShortSelling; ! this.startDate = startDate; ! this.endDate = endDate; ! this.maxRunningHours = maxRunningHours; ! this.scriptName = "DoubleOverReaction_WeekEndBounce"; ! this.historicalMarketValueProvider = new HistoricalAdjustedQuoteProvider(); ! this.timer = new IndexBasedEndOfDayTimer( ! HistoricalEndOfDayTimer.GetMarketOpen( this.startDate ) , this.benchmark ); ! // new EndOfDayDateTime( this.startDate , ! // EndOfDaySpecificTime.MarketOpen ) , this.benchmark ); this.lengthInDaysForPerformance = lengthInDaysForPerformance; ! } ! public void Run() ! { ! this.startingTimeForScript = DateTime.Now; ! this.account = new Account( "WeekEndBounce" , this.timer , ! new HistoricalEndOfDayDataStreamer( this.timer , ! this.historicalMarketValueProvider ) , ! new HistoricalEndOfDayOrderExecutor( this.timer , ! this.historicalMarketValueProvider ) ); ! EndOfDayTimerHandlerDOR_WeekEndBounce endOfDayTimerHandler = ! new EndOfDayTimerHandlerDOR_WeekEndBounce(this.tickerGroupID, this.numberOfEligibleTickers, ! this.numOfBestTickers, this.numOfWorstTickers, this.lengthInDaysForPerformance, ! this.numOfTickersForBuying, this.numOfTickersForShortSelling, ! this.account, this.benchmark); ! this.timer.NewDateTime += new NewDateTimeEventHandler( ! endOfDayTimerHandler.NewDateTimeEventHandler ); ! ! // this.timer.MarketOpen += new MarketOpenEventHandler( ! // endOfDayTimerHandler.MarketOpenEventHandler ); ! // ! // this.timer.MarketClose += new MarketCloseEventHandler( ! // endOfDayTimerHandler.MarketCloseEventHandler ); ! this.timer.NewDateTime += new NewDateTimeEventHandler( ! this.checkDateForReport); ! // this.timer.OneHourAfterMarketClose += new OneHourAfterMarketCloseEventHandler( ! // endOfDayTimerHandler.OneHourAfterMarketCloseEventHandler ); ! ! this.timer.Start(); ! } ! private void checkDateForReport( ! Object sender , DateTime dateTime) ! { ! if ( HistoricalEndOfDayTimer.IsMarketClose( dateTime ) ) ! { ! if( dateTime >= this.endDate || ! 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.SaveScriptResults(); ! } ! } ! private void checkDateForReport_createDirIfNotPresent(string dirPath) ! { ! if(!Directory.Exists(dirPath)) ! Directory.CreateDirectory(dirPath); ! } ! public void SaveScriptResults() ! { ! TimeSpan span; span = DateTime.Now.Subtract(this.startingTimeForScript); int secondsElapsed = span.Hours * 3600 + span.Minutes * 60 + span.Seconds; ! string fileName = ! "SecondsElapsed_" + secondsElapsed.ToString() + "_" + ! DateTime.Now.Hour.ToString().PadLeft(2,'0') + "_" + ! DateTime.Now.Minute.ToString().PadLeft(2,'0') + "_" + ! this.scriptName + "_From_" + this.tickerGroupID + ! "_elig_" + this.numberOfEligibleTickers + ! "_best_" + this.numOfBestTickers + ! "_worst_" + this.numOfWorstTickers + ! "_forLong_" + this.numOfTickersForBuying + ! "_forShort_" + this.numOfTickersForShortSelling; ! string dirNameWhereToSaveReports = ! System.Configuration.ConfigurationManager.AppSettings["ReportsArchive"] + ! "\\" + this.scriptName + "\\"; ! ! //default report with numIntervalDays = 1 ! AccountReport accountReport = this.account.CreateReport( fileName,1, ! this.timer.GetCurrentDateTime(), ! this.benchmark, ! new HistoricalAdjustedQuoteProvider() ); ! this.checkDateForReport_createDirIfNotPresent(dirNameWhereToSaveReports); ! ObjectArchiver.Archive(accountReport, ! dirNameWhereToSaveReports + ! fileName + ".qPr"); ! ! this.timer.Stop(); ! } ! } } |
|
From: Glauco S. <gla...@us...> - 2008-09-29 21:17:15
|
Update of /cvsroot/quantproject/QuantProject/b4_Business/a2_Strategies/TickersRelationships In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv15532/TickersRelationships Modified Files: OpenToCloseCloseToOpenCorrelationProvider.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: OpenToCloseCloseToOpenCorrelationProvider.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b4_Business/a2_Strategies/TickersRelationships/OpenToCloseCloseToOpenCorrelationProvider.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** OpenToCloseCloseToOpenCorrelationProvider.cs 25 Apr 2008 17:28:05 -0000 1.1 --- OpenToCloseCloseToOpenCorrelationProvider.cs 29 Sep 2008 21:16:51 -0000 1.2 *************** *** 88,97 **** } ! protected override void setEndOfDayDatesTime(DateTime startDate, DateTime endDate) { ! this.firstEndOfDayDateTime = ! new EndOfDayDateTime(startDate, EndOfDaySpecificTime.MarketOpen); ! this.lastEndOfDayDateTime = ! new EndOfDayDateTime(endDate, EndOfDaySpecificTime.MarketClose); } --- 88,100 ---- } ! protected override void setEndOfDayDatesTime( ! DateTime firstDate, DateTime lastDate) { ! this.firstDateTime = ! HistoricalEndOfDayTimer.GetMarketOpen( firstDate); ! // new EndOfDayDateTime(firstDate, EndOfDaySpecificTime.MarketOpen); ! this.lastDateTime = ! HistoricalEndOfDayTimer.GetMarketClose( lastDate ); ! // new EndOfDayDateTime(lastDate, EndOfDaySpecificTime.MarketClose); } *************** *** 99,103 **** { OpenToCloseCloseToOpenIntervals openToCloseCloseToOpenIntervals = ! new OpenToCloseCloseToOpenIntervals(this.firstEndOfDayDateTime, this.lastEndOfDayDateTime, this.benchmark); this.returnsManager = --- 102,106 ---- { OpenToCloseCloseToOpenIntervals openToCloseCloseToOpenIntervals = ! new OpenToCloseCloseToOpenIntervals(this.firstDateTime, this.lastDateTime, this.benchmark); this.returnsManager = |
|
From: Glauco S. <gla...@us...> - 2008-09-29 21:17:14
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/ArbitrageTesting/PairTrading In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv15453/PairTrading Modified Files: RunPairTrading.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: RunPairTrading.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/ArbitrageTesting/PairTrading/RunPairTrading.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** RunPairTrading.cs 19 Aug 2008 17:13:09 -0000 1.2 --- RunPairTrading.cs 29 Sep 2008 21:16:40 -0000 1.3 *************** *** 3,7 **** RunPairTrading.cs ! Copyright (C) 2003 Marco Milletti --- 3,7 ---- RunPairTrading.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; *************** *** 40,44 **** using QuantProject.Business.Financial.Accounting.Commissions; using QuantProject.Data.DataProviders; ! using QuantProject.Data.Selectors; using QuantProject.Presentation.Reporting.WindowsForm; using QuantProject.Scripts.WalkForwardTesting.LinearCombination; --- 40,44 ---- using QuantProject.Business.Financial.Accounting.Commissions; using QuantProject.Data.DataProviders; ! using QuantProject.Data.Selectors; using QuantProject.Presentation.Reporting.WindowsForm; using QuantProject.Scripts.WalkForwardTesting.LinearCombination; *************** *** 52,255 **** /// </summary> [Serializable] ! public class RunPairTrading { ! protected string tickerGroupID; ! protected int numberOfEligibleTickers; ! protected int numDaysForOptimizationPeriod; ! protected int generationNumberForGeneticOptimizer; ! protected int populationSizeForGeneticOptimizer; ! protected EndOfDayDateTime startDateTime; ! protected EndOfDayDateTime endDateTime; ! protected IHistoricalQuoteProvider historicalQuoteProvider; ! protected Account account; ! protected IEndOfDayTimer endOfDayTimer; ! protected string benchmark; ! ! protected string scriptName; ! ! protected double maxNumOfStdDevForNormalGap; ! protected int minNumOfDaysForGapComputation; ! protected int maxNumOfDaysForGapComputation; ! protected int numDaysBetweenEachOptimization; ! protected DateTime startingTimeForScript; ! protected double maxRunningHours; ! //if MaxNumberOfHoursForScript has elapsed and the script ! //is still running, it will be stopped. ! ! public virtual string ScriptName ! { ! get{return this.scriptName;} ! set{this.scriptName = value;} ! } ! ! public DateTime TimerLastDate ! { ! get{return this.endOfDayTimer.GetCurrentTime().DateTime ;} ! } ! // public RunPairTrading(string benchmark, ! // DateTime startDate, DateTime endDate, ! // double maxLevelForNormalGap, ! // double maxRunningHours) // { ! // ! // this.startDateTime = new EndOfDayDateTime( ! // startDate, EndOfDaySpecificTime.FiveMinutesBeforeMarketClose ); ! // this.endDateTime = new EndOfDayDateTime( ! // endDate, EndOfDaySpecificTime.OneHourAfterMarketClose ); ! // this.maxLevelForNormalGap = maxLevelForNormalGap; ! // this.benchmark = benchmark; ! // this.ScriptName = "EfficientGeneric"; ! // this.startingTimeForScript = DateTime.Now; ! // this.maxRunningHours = maxRunningHours; ! // //this.numIntervalDays = 3; // } ! ! public RunPairTrading(string tickerGroupID, int numberOfEligibleTickers, ! int numDaysForOptimizationPeriod, ! int generationNumberForGeneticOptimizer, ! int populationSizeForGeneticOptimizer, string benchmark, ! DateTime startDate, DateTime endDate, ! int minNumOfDaysForGapComputation, int maxNumOfDaysForGapComputation, ! double maxNumOfStdDevForNormalGap, int numDaysBetweenEachOptimization, ! double maxRunningHours) { ! //this.progressBarForm = new ProgressBarForm(); ! this.tickerGroupID = tickerGroupID; ! this.numberOfEligibleTickers = numberOfEligibleTickers; ! this.numDaysForOptimizationPeriod = numDaysForOptimizationPeriod; ! this.generationNumberForGeneticOptimizer = generationNumberForGeneticOptimizer; ! this.populationSizeForGeneticOptimizer = populationSizeForGeneticOptimizer; ! this.startDateTime = new EndOfDayDateTime( ! startDate, EndOfDaySpecificTime.FiveMinutesBeforeMarketClose ); ! this.endDateTime = new EndOfDayDateTime( ! endDate, EndOfDaySpecificTime.OneHourAfterMarketClose ); ! this.benchmark = benchmark; ! this.ScriptName = "PairTradingGeneric"; ! this.maxNumOfStdDevForNormalGap = maxNumOfStdDevForNormalGap; ! this.minNumOfDaysForGapComputation = minNumOfDaysForGapComputation; ! this.maxNumOfDaysForGapComputation = maxNumOfDaysForGapComputation; ! this.numDaysBetweenEachOptimization = numDaysBetweenEachOptimization; ! this.startingTimeForScript = DateTime.Now; ! this.maxRunningHours = maxRunningHours; ! //this.numIntervalDays = 3; } ! ! ! #region Run ! ! protected virtual void run_initializeEndOfDayTimer() ! { ! //default endOfDayTimer ! this.endOfDayTimer = ! new IndexBasedEndOfDayTimer( this.startDateTime, this.benchmark ); ! ! } ! ! protected virtual void run_initializeAccount() ! { ! //default account with no commissions and no slippage calculation ! this.account = new Account( this.scriptName , this.endOfDayTimer , ! new HistoricalEndOfDayDataStreamer( this.endOfDayTimer , ! this.historicalQuoteProvider ) , ! new HistoricalEndOfDayOrderExecutor( this.endOfDayTimer , ! this.historicalQuoteProvider )); ! ! } ! protected virtual void run_initializeEndOfDayTimerHandler() ! { ! //always needs specific implementation in inherited classes; ! } ! ! protected virtual void run_initializeHistoricalQuoteProvider() ! { ! this.historicalQuoteProvider = new HistoricalAdjustedQuoteProvider(); ! } ! ! protected void checkDateForReport_createDirIfNotPresent(string dirPath) ! { ! if(!Directory.Exists(dirPath)) ! Directory.CreateDirectory(dirPath); ! } ! ! protected virtual 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.SaveScriptResults(); ! } ! ! public virtual void SaveScriptResults() ! { ! string fileName = "From"+this.numberOfEligibleTickers + ! "OptDays" + this.numDaysForOptimizationPeriod + "GenNum" + ! this.generationNumberForGeneticOptimizer + ! "PopSize" + this.populationSizeForGeneticOptimizer; ! string dirNameWhereToSaveReports = ! System.Configuration.ConfigurationManager.AppSettings["ReportsArchive"] + ! "\\" + this.ScriptName + "\\"; ! string dirNameWhereToSaveTransactions = ! System.Configuration.ConfigurationManager.AppSettings["TransactionsArchive"] + ! "\\" + this.ScriptName + "\\"; ! // string dirNameWhereToSaveBestGenomes = System.Configuration.ConfigurationSettings.AppSettings["GenomesArchive"] + ! // "\\" + this.ScriptName + "\\"; ! //default report with numIntervalDays = 1 ! AccountReport accountReport = this.account.CreateReport(fileName,1, ! this.endOfDayTimer.GetCurrentTime(), ! this.benchmark, ! new HistoricalAdjustedQuoteProvider()); ! this.checkDateForReport_createDirIfNotPresent(dirNameWhereToSaveReports); ! ObjectArchiver.Archive(accountReport, ! dirNameWhereToSaveReports + ! fileName + ".qPr"); ! // ! this.checkDateForReport_createDirIfNotPresent(dirNameWhereToSaveTransactions); ! ObjectArchiver.Archive(this.account.Transactions, ! dirNameWhereToSaveTransactions + ! fileName + ".qPt"); ! // ! // this.checkDateForReport_createDirIfNotPresent(dirNameWhereToSaveBestGenomes); ! ! this.endOfDayTimer.Stop(); ! ! } ! ! protected virtual void run_initialize() ! { ! run_initializeHistoricalQuoteProvider(); ! run_initializeEndOfDayTimer(); ! run_initializeAccount(); ! run_initializeEndOfDayTimerHandler(); ! //run_initializeProgressHandlers(); ! } ! protected virtual void run_addEventHandlers() ! { ! this.endOfDayTimer.MarketClose += ! new MarketCloseEventHandler( ! this.checkDateForReport); ! ! //in inherited classes'override method: ! //add here TimerHandler's handlers to timer's events ! //example ! //this.endOfDayTimer.EVENT_NAME += ! // new EVENT_NAMEEventHandler( ! // this.endOfDayTimerHandler.EVENT_NAMEEventHandler); ! } ! ! ! public virtual void Run() ! { ! this.run_initialize(); ! this.run_addEventHandlers(); ! //this.progressBarForm.Show(); ! this.endOfDayTimer.Start(); ! } ! ! #endregion ! } } --- 52,263 ---- /// </summary> [Serializable] ! public class RunPairTrading { ! protected string tickerGroupID; ! protected int numberOfEligibleTickers; ! protected int numDaysForOptimizationPeriod; ! protected int generationNumberForGeneticOptimizer; ! protected int populationSizeForGeneticOptimizer; ! protected DateTime startDateTime; ! protected DateTime endDateTime; ! protected HistoricalMarketValueProvider historicalMarketValueProvider; ! protected Account account; ! protected QuantProject.Business.Timing.Timer timer; ! protected string benchmark; ! ! protected string scriptName; ! ! protected double maxNumOfStdDevForNormalGap; ! protected int minNumOfDaysForGapComputation; ! protected int maxNumOfDaysForGapComputation; ! protected int numDaysBetweenEachOptimization; ! protected DateTime startingTimeForScript; ! protected double maxRunningHours; ! //if MaxNumberOfHoursForScript has elapsed and the script ! //is still running, it will be stopped. ! ! public virtual string ScriptName ! { ! get{return this.scriptName;} ! set{this.scriptName = value;} ! } ! ! public DateTime TimerLastDate ! { ! get{return this.timer.GetCurrentDateTime() ;} ! } ! // public RunPairTrading(string benchmark, ! // DateTime startDate, DateTime endDate, ! // double maxLevelForNormalGap, ! // double maxRunningHours) // { ! // ! // this.startDateTime = new EndOfDayDateTime( ! // startDate, EndOfDaySpecificTime.FiveMinutesBeforeMarketClose ); ! // this.endDateTime = new EndOfDayDateTime( ! // endDate, EndOfDaySpecificTime.OneHourAfterMarketClose ); ! // this.maxLevelForNormalGap = maxLevelForNormalGap; ! // this.benchmark = benchmark; ! // this.ScriptName = "EfficientGeneric"; ! // this.startingTimeForScript = DateTime.Now; ! // this.maxRunningHours = maxRunningHours; ! // //this.numIntervalDays = 3; // } ! ! public RunPairTrading(string tickerGroupID, int numberOfEligibleTickers, ! int numDaysForOptimizationPeriod, ! int generationNumberForGeneticOptimizer, ! int populationSizeForGeneticOptimizer, string benchmark, ! DateTime startDate, DateTime endDate, ! int minNumOfDaysForGapComputation, int maxNumOfDaysForGapComputation, ! double maxNumOfStdDevForNormalGap, int numDaysBetweenEachOptimization, ! double maxRunningHours) { ! //this.progressBarForm = new ProgressBarForm(); ! this.tickerGroupID = tickerGroupID; ! this.numberOfEligibleTickers = numberOfEligibleTickers; ! this.numDaysForOptimizationPeriod = numDaysForOptimizationPeriod; ! this.generationNumberForGeneticOptimizer = generationNumberForGeneticOptimizer; ! this.populationSizeForGeneticOptimizer = populationSizeForGeneticOptimizer; ! this.startDateTime = ! HistoricalEndOfDayTimer.GetFiveMinutesBeforeMarketClose( startDate ); ! // new EndOfDayDateTime( ! // startDate, EndOfDaySpecificTime.FiveMinutesBeforeMarketClose ); ! this.endDateTime = ! HistoricalEndOfDayTimer.GetOneHourAfterMarketClose( endDate ); ! // new EndOfDayDateTime( ! // endDate, EndOfDaySpecificTime.OneHourAfterMarketClose ); ! this.benchmark = benchmark; ! this.ScriptName = "PairTradingGeneric"; ! this.maxNumOfStdDevForNormalGap = maxNumOfStdDevForNormalGap; ! this.minNumOfDaysForGapComputation = minNumOfDaysForGapComputation; ! this.maxNumOfDaysForGapComputation = maxNumOfDaysForGapComputation; ! this.numDaysBetweenEachOptimization = numDaysBetweenEachOptimization; ! this.startingTimeForScript = DateTime.Now; ! this.maxRunningHours = maxRunningHours; ! //this.numIntervalDays = 3; } ! ! ! #region Run ! ! protected virtual void run_initializeEndOfDayTimer() ! { ! //default endOfDayTimer ! this.timer = ! new IndexBasedEndOfDayTimer( this.startDateTime, this.benchmark ); ! ! } ! ! protected virtual void run_initializeAccount() ! { ! //default account with no commissions and no slippage calculation ! this.account = new Account( this.scriptName , this.timer , ! new HistoricalEndOfDayDataStreamer( this.timer , ! this.historicalMarketValueProvider ) , ! new HistoricalEndOfDayOrderExecutor( this.timer , ! this.historicalMarketValueProvider )); ! ! } ! protected virtual void run_initializeEndOfDayTimerHandler() ! { ! //always needs specific implementation in inherited classes; ! } ! ! protected virtual void run_initializeHistoricalQuoteProvider() ! { ! this.historicalMarketValueProvider = new HistoricalAdjustedQuoteProvider(); ! } ! ! protected void checkDateForReport_createDirIfNotPresent(string dirPath) ! { ! if(!Directory.Exists(dirPath)) ! Directory.CreateDirectory(dirPath); ! } ! ! protected virtual 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.SaveScriptResults(); ! } ! ! public virtual void SaveScriptResults() ! { ! string fileName = "From"+this.numberOfEligibleTickers + ! "OptDays" + this.numDaysForOptimizationPeriod + "GenNum" + ! this.generationNumberForGeneticOptimizer + ! "PopSize" + this.populationSizeForGeneticOptimizer; ! string dirNameWhereToSaveReports = ! System.Configuration.ConfigurationManager.AppSettings["ReportsArchive"] + ! "\\" + this.ScriptName + "\\"; ! string dirNameWhereToSaveTransactions = ! System.Configuration.ConfigurationManager.AppSettings["TransactionsArchive"] + ! "\\" + this.ScriptName + "\\"; ! // string dirNameWhereToSaveBestGenomes = System.Configuration.ConfigurationSettings.AppSettings["GenomesArchive"] + ! // "\\" + this.ScriptName + "\\"; ! //default report with numIntervalDays = 1 ! AccountReport accountReport = this.account.CreateReport(fileName,1, ! this.timer.GetCurrentDateTime(), ! this.benchmark, ! new HistoricalAdjustedQuoteProvider()); ! this.checkDateForReport_createDirIfNotPresent(dirNameWhereToSaveReports); ! ObjectArchiver.Archive(accountReport, ! dirNameWhereToSaveReports + ! fileName + ".qPr"); ! // ! this.checkDateForReport_createDirIfNotPresent(dirNameWhereToSaveTransactions); ! ObjectArchiver.Archive(this.account.Transactions, ! dirNameWhereToSaveTransactions + ! fileName + ".qPt"); ! // ! // this.checkDateForReport_createDirIfNotPresent(dirNameWhereToSaveBestGenomes); ! ! this.timer.Stop(); ! ! } ! ! protected virtual void run_initialize() ! { ! run_initializeHistoricalQuoteProvider(); ! run_initializeEndOfDayTimer(); ! run_initializeAccount(); ! run_initializeEndOfDayTimerHandler(); ! //run_initializeProgressHandlers(); ! } ! protected virtual void run_addEventHandlers() ! { ! this.timer.NewDateTime += ! new NewDateTimeEventHandler( this.checkDateForReport ); ! ! // this.timer.MarketClose += ! // new MarketCloseEventHandler( ! // this.checkDateForReport); ! ! //in inherited classes'override method: ! //add here TimerHandler's handlers to timer's events ! //example ! //this.endOfDayTimer.EVENT_NAME += ! // new EVENT_NAMEEventHandler( ! // this.endOfDayTimerHandler.EVENT_NAMEEventHandler); ! } ! ! ! public virtual void Run() ! { ! this.run_initialize(); ! this.run_addEventHandlers(); ! //this.progressBarForm.Show(); ! this.timer.Start(); ! } ! ! #endregion ! } } |
|
From: Glauco S. <gla...@us...> - 2008-09-29 21:17:10
|
Update of /cvsroot/quantproject/QuantProject/b4_Business/a2_Strategies/Optimizing/GenomeManagers In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv15532/Optimizing/GenomeManagers Modified Files: GenomeManagerWithDuplicateGenes.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: GenomeManagerWithDuplicateGenes.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b4_Business/a2_Strategies/Optimizing/GenomeManagers/GenomeManagerWithDuplicateGenes.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** GenomeManagerWithDuplicateGenes.cs 27 Feb 2008 21:39:46 -0000 1.1 --- GenomeManagerWithDuplicateGenes.cs 29 Sep 2008 21:16:51 -0000 1.2 *************** *** 35,38 **** --- 35,39 ---- /// Genome manager with duplicate genes /// </summary> + [Serializable] public class GenomeManagerWithDuplicateGenes : BasicGenomeManager { |
|
From: Glauco S. <gla...@us...> - 2008-09-29 21:17:09
|
Update of /cvsroot/quantproject/QuantProject/b4_Business/a2_Strategies In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv15371 Modified Files: EndOfDayStrategyBackTester.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: EndOfDayStrategyBackTester.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b4_Business/a2_Strategies/EndOfDayStrategyBackTester.cs,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** EndOfDayStrategyBackTester.cs 19 Mar 2008 23:21:33 -0000 1.9 --- EndOfDayStrategyBackTester.cs 29 Sep 2008 21:16:18 -0000 1.10 *************** *** 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; *************** *** 29,33 **** using QuantProject.Business.Financial.Accounting; using QuantProject.Business.Financial.Accounting.Reporting; ! using QuantProject.Business.Financial.Accounting.AccountProviding; using QuantProject.Business.Financial.Ordering; using QuantProject.Business.Strategies.Logging; --- 29,33 ---- using QuantProject.Business.Financial.Accounting; using QuantProject.Business.Financial.Accounting.Reporting; ! using QuantProject.Business.Financial.Accounting.AccountProviding; using QuantProject.Business.Financial.Ordering; using QuantProject.Business.Strategies.Logging; *************** *** 39,49 **** /// Performs a backtest for an end of day strategy /// </summary> public class EndOfDayStrategyBackTester : IMessageSender , ILogDescriptor { public event NewMessageEventHandler NewMessage; private string backTestID; ! private IEndOfDayStrategyForBacktester endOfDayStrategy; ! private IHistoricalQuoteProvider historicalQuoteProvider; private DateTime firstDateTime; private DateTime lastDateTime; --- 39,57 ---- /// Performs a backtest for an end of day strategy /// </summary> + [Serializable] public class EndOfDayStrategyBackTester : IMessageSender , ILogDescriptor { public event NewMessageEventHandler NewMessage; + + // the following event is used to avoid the strategy receiving + // NewDateTime events directly from the timer: this way the + // strategy does not receive any new message once the backtester + // has been completed + private event NewDateTimeEventHandler newDateTime; + private string backTestID; ! private IStrategyForBacktester strategyForBacktester; ! private HistoricalMarketValueProvider historicalMarketValueProvider; private DateTime firstDateTime; private DateTime lastDateTime; *************** *** 53,57 **** private IAccountProvider accountProvider; private DateTime startingTimeForScript; ! private IEndOfDayTimer endOfDayTimer; private DateTime actualLastDateTime; private Account account; --- 61,65 ---- private IAccountProvider accountProvider; private DateTime startingTimeForScript; ! private Timer timer; private DateTime actualLastDateTime; private Account account; *************** *** 60,66 **** private DateTime realDateTimeWhenTheBackTestIsStopped; ! public IHistoricalQuoteProvider HistoricalQuoteProvider { ! get { return this.historicalQuoteProvider; } } public Benchmark Benchmark --- 68,74 ---- private DateTime realDateTimeWhenTheBackTestIsStopped; ! public HistoricalMarketValueProvider HistoricalMarketValueProvider { ! get { return this.historicalMarketValueProvider; } } public Benchmark Benchmark *************** *** 117,125 **** /// The timer used by the backtester, to simulate the time ticking /// </summary> ! public IEndOfDayTimer EndOfDayTimer { get { ! return this.endOfDayTimer; } } --- 125,133 ---- /// The timer used by the backtester, to simulate the time ticking /// </summary> ! public Timer Timer { get { ! return this.timer; } } *************** *** 130,134 **** string description = ExtendedDateTime.GetCompleteShortDescriptionForFileName( ! this.realDateTimeWhenTheBackTestIsStopped ) + "_" + "from_" + ExtendedDateTime.GetShortDescriptionForFileName( this.firstDateTime ) + --- 138,142 ---- string description = ExtendedDateTime.GetCompleteShortDescriptionForFileName( ! this.realDateTimeWhenTheBackTestIsStopped ) + "_" + "from_" + ExtendedDateTime.GetShortDescriptionForFileName( this.firstDateTime ) + *************** *** 137,142 **** "_annlRtrn_" + this.AccountReport.Summary.AnnualSystemPercentageReturn.FormattedValue + "_maxDD_" + this.AccountReport.Summary.MaxEquityDrawDown.FormattedValue + ! "_" + this.historicalQuoteProvider.Description + ! "_" + this.endOfDayStrategy.Description; return description.Substring( 0 , Math.Min( description.Length , 200 ) ); } --- 145,150 ---- "_annlRtrn_" + this.AccountReport.Summary.AnnualSystemPercentageReturn.FormattedValue + "_maxDD_" + this.AccountReport.Summary.MaxEquityDrawDown.FormattedValue + ! "_" + this.historicalMarketValueProvider.Description + ! "_" + this.strategyForBacktester.Description; return description.Substring( 0 , Math.Min( description.Length , 200 ) ); } *************** *** 148,166 **** // the timer has not been stopped yet throw new Exception( "This property cannot be invoked " + ! "while the backtest is still running!" ); } public EndOfDayStrategyBackTester( string backTestID , ! IEndOfDayStrategyForBacktester endOfDayStrategy , ! IHistoricalQuoteProvider historicalQuoteProvider , ! IAccountProvider accountProvider, ! DateTime firstDateTime , DateTime lastDateTime , ! Benchmark benchmark , ! double cashToStart , ! double maxRunningHours ) { ! this.endOfDayStrategyBackTester_checkParameters( ! endOfDayStrategy , ! historicalQuoteProvider , accountProvider, firstDateTime , lastDateTime , --- 156,174 ---- // the timer has not been stopped yet throw new Exception( "This property cannot be invoked " + ! "while the backtest is still running!" ); } public EndOfDayStrategyBackTester( string backTestID , ! IStrategyForBacktester strategyForBacktester , ! HistoricalMarketValueProvider historicalMarketValueProvider , ! IAccountProvider accountProvider, ! DateTime firstDateTime , DateTime lastDateTime , ! Benchmark benchmark , ! double cashToStart , ! double maxRunningHours ) { ! this.endOfDayStrategyBackTester_checkParameters( ! strategyForBacktester , ! historicalMarketValueProvider , accountProvider, firstDateTime , lastDateTime , *************** *** 169,174 **** maxRunningHours ); this.backTestID = backTestID; ! this.endOfDayStrategy = endOfDayStrategy; ! this.historicalQuoteProvider = historicalQuoteProvider; this.accountProvider = accountProvider; this.firstDateTime = firstDateTime; --- 177,182 ---- maxRunningHours ); this.backTestID = backTestID; ! this.strategyForBacktester = strategyForBacktester; ! this.historicalMarketValueProvider = historicalMarketValueProvider; this.accountProvider = accountProvider; this.firstDateTime = firstDateTime; *************** *** 178,193 **** this.maxRunningHours = maxRunningHours; ! this.initialize_endOfDayTimer(); ! this.account = this.accountProvider.GetAccount(this.endOfDayTimer, ! this.historicalQuoteProvider); ! this.endOfDayStrategy.Account = this.account; this.backTestLog = new BackTestLog( backTestID , firstDateTime , ! lastDateTime , benchmark ); this.actualLastDateTime = DateTime.MinValue; this.realDateTimeWhenTheBackTestIsStopped = DateTime.MinValue; } private void endOfDayStrategyBackTester_checkParameters( ! IEndOfDayStrategyForBacktester endOfDayStrategy , ! IHistoricalQuoteProvider historicalQuoteProvider , IAccountProvider accountProvider, DateTime firstDateTime , DateTime lastDateTime , --- 186,201 ---- this.maxRunningHours = maxRunningHours; ! this.initialize_endOfDayTimer(); ! this.account = this.accountProvider.GetAccount( ! this.timer, this.historicalMarketValueProvider); ! this.strategyForBacktester.Account = this.account; this.backTestLog = new BackTestLog( backTestID , firstDateTime , ! lastDateTime , benchmark ); this.actualLastDateTime = DateTime.MinValue; this.realDateTimeWhenTheBackTestIsStopped = DateTime.MinValue; } private void endOfDayStrategyBackTester_checkParameters( ! IStrategyForBacktester strategyForBacktester , ! HistoricalMarketValueProvider historicalMarketValueProvider , IAccountProvider accountProvider, DateTime firstDateTime , DateTime lastDateTime , *************** *** 196,202 **** double maxRunningHours ) { ! if ( endOfDayStrategy == null ) throw new Exception( "endOfDayStrategy cannot be null!" ); ! if ( historicalQuoteProvider == null ) throw new Exception( "historicalQuoteProvider cannot be null!" ); if ( accountProvider == null ) --- 204,210 ---- double maxRunningHours ) { ! if ( strategyForBacktester == null ) throw new Exception( "endOfDayStrategy cannot be null!" ); ! if ( historicalMarketValueProvider == null ) throw new Exception( "historicalQuoteProvider cannot be null!" ); if ( accountProvider == null ) *************** *** 212,221 **** private void initialize_endOfDayTimer() { ! EndOfDayDateTime endOfDayDateTime = ! new EndOfDayDateTime( this.firstDateTime , ! EndOfDaySpecificTime.MarketOpen ); ! this.endOfDayTimer = ! new IndexBasedEndOfDayTimer( endOfDayDateTime , ! this.benchmark.Ticker ); } --- 220,229 ---- private void initialize_endOfDayTimer() { ! DateTime startingDateTime = HistoricalEndOfDayTimer.GetMarketOpen( ! this.firstDateTime ); ! // new EndOfDayDateTime( this.firstDateTime , ! // EndOfDaySpecificTime.MarketOpen ); ! this.timer = new IndexBasedEndOfDayTimer( ! startingDateTime , this.benchmark.Ticker ); } *************** *** 223,227 **** #region run_addEventHandlers private void handlerToAddCashToStart( ! Object sender , EndOfDayTimingEventArgs endOfDayTimingEventArgs ) { if ( this.account.Transactions.Count == 0 ) --- 231,235 ---- #region run_addEventHandlers private void handlerToAddCashToStart( ! Object sender , DateTime dateTime ) { if ( this.account.Transactions.Count == 0 ) *************** *** 231,272 **** private void run_addEventHandlers_addHandlersToAddCashToStart() { ! this.endOfDayTimer.MarketOpen += ! new MarketOpenEventHandler( ! this.handlerToAddCashToStart ); ! this.endOfDayTimer.FiveMinutesBeforeMarketClose += ! new FiveMinutesBeforeMarketCloseEventHandler( ! this.handlerToAddCashToStart ); ! this.endOfDayTimer.MarketClose += ! new MarketCloseEventHandler( ! this.handlerToAddCashToStart ); ! this.endOfDayTimer.OneHourAfterMarketClose += ! new OneHourAfterMarketCloseEventHandler( ! this.handlerToAddCashToStart ); } private void run_addEventHandlers_addStrategyHandlers() { ! this.endOfDayTimer.MarketOpen += ! new MarketOpenEventHandler( ! this.endOfDayStrategy.MarketOpenEventHandler ); ! this.endOfDayTimer.FiveMinutesBeforeMarketClose += ! new FiveMinutesBeforeMarketCloseEventHandler( ! this.endOfDayStrategy.FiveMinutesBeforeMarketCloseEventHandler ); ! this.endOfDayTimer.OneHourAfterMarketClose += ! new OneHourAfterMarketCloseEventHandler( ! this.endOfDayStrategy.OneHourAfterMarketCloseEventHandler ); ! this.endOfDayTimer.MarketClose += ! new MarketCloseEventHandler( ! this.endOfDayStrategy.MarketCloseEventHandler ); } private void run_addEventHandlers() { this.run_addEventHandlers_addHandlersToAddCashToStart(); this.run_addEventHandlers_addStrategyHandlers(); ! this.endOfDayTimer.MarketClose += ! new MarketCloseEventHandler( ! this.marketCloseEventHandler ); ! this.endOfDayStrategy.NewLogItem += new NewLogItemEventHandler( ! this.newLogItemEventHandler ); } #endregion run_addEventHandlers --- 239,292 ---- private void run_addEventHandlers_addHandlersToAddCashToStart() { ! this.newDateTime += ! new NewDateTimeEventHandler( ! this.handlerToAddCashToStart ); ! // this.timer.NewDateTime += ! // new NewDateTimeEventHandler( ! // this.handlerToAddCashToStart ); ! ! // this.endOfDayTimer.MarketOpen += ! // new MarketOpenEventHandler( ! // this.handlerToAddCashToStart ); ! // this.endOfDayTimer.FiveMinutesBeforeMarketClose += ! // new FiveMinutesBeforeMarketCloseEventHandler( ! // this.handlerToAddCashToStart ); ! // this.endOfDayTimer.MarketClose += ! // new MarketCloseEventHandler( ! // this.handlerToAddCashToStart ); ! // this.endOfDayTimer.OneHourAfterMarketClose += ! // new OneHourAfterMarketCloseEventHandler( ! // this.handlerToAddCashToStart ); } private void run_addEventHandlers_addStrategyHandlers() { ! this.newDateTime += ! new NewDateTimeEventHandler( ! this.strategyForBacktester.NewDateTimeEventHandler ); ! // this.endOfDayTimer.MarketOpen += ! // new MarketOpenEventHandler( ! // this.endOfDayStrategy.MarketOpenEventHandler ); ! // this.endOfDayTimer.FiveMinutesBeforeMarketClose += ! // new FiveMinutesBeforeMarketCloseEventHandler( ! // this.endOfDayStrategy.FiveMinutesBeforeMarketCloseEventHandler ); ! // this.endOfDayTimer.OneHourAfterMarketClose += ! // new OneHourAfterMarketCloseEventHandler( ! // this.endOfDayStrategy.OneHourAfterMarketCloseEventHandler ); ! // this.endOfDayTimer.MarketClose += ! // new MarketCloseEventHandler( ! // this.endOfDayStrategy.MarketCloseEventHandler ); } private void run_addEventHandlers() { this.run_addEventHandlers_addHandlersToAddCashToStart(); + this.timer.NewDateTime += + new NewDateTimeEventHandler( this.newDateTimeEventHandler ); this.run_addEventHandlers_addStrategyHandlers(); ! // this.endOfDayTimer.MarketClose += ! // new MarketCloseEventHandler( ! // this.marketCloseEventHandler ); ! this.strategyForBacktester.NewLogItem += new NewLogItemEventHandler( ! this.newLogItemEventHandler ); } #endregion run_addEventHandlers *************** *** 284,311 **** run_addEventHandlers(); // this.progressBarForm.Show(); ! this.endOfDayTimer.Start(); } #endregion Run ! #region marketCloseEventHandler private bool isTimeToStop( DateTime currentTime ) { DateTime maxEndingDateTimeForScript = this.startingTimeForScript.AddHours( this.maxRunningHours ); ! bool scriptTimeElapsed = ( DateTime.Now >= maxEndingDateTimeForScript ); bool stopBacktestIfMaxRunningHoursHasBeenReached = ! this.endOfDayStrategy.StopBacktestIfMaxRunningHoursHasBeenReached; return ( ( currentTime > this.lastDateTime ) || ! ( scriptTimeElapsed && ! stopBacktestIfMaxRunningHoursHasBeenReached ) ); } ! private void marketCloseEventHandler_notifyProgress( ! IEndOfDayTimer endOfDayTimer ) { string progressMessage = "Current out of sample date:" + ! endOfDayTimer.GetCurrentTime().DateTime.ToString() + " - " + "First date:" + this.firstDateTime.ToString() + " - " + ! "Last date:" + this.lastDateTime.ToString(); NewMessageEventArgs newMessageEventArgs = new NewMessageEventArgs( progressMessage ); --- 304,373 ---- run_addEventHandlers(); // this.progressBarForm.Show(); ! this.timer.Start(); } #endregion Run ! #region newDateTimeEventHandler ! private bool isTimeToStop( DateTime currentTime ) { DateTime maxEndingDateTimeForScript = this.startingTimeForScript.AddHours( this.maxRunningHours ); ! DateTime realTime = DateTime.Now; ! bool scriptTimeElapsed = ( realTime >= maxEndingDateTimeForScript ); bool stopBacktestIfMaxRunningHoursHasBeenReached = ! this.strategyForBacktester.StopBacktestIfMaxRunningHoursHasBeenReached; return ( ( currentTime > this.lastDateTime ) || ! ( scriptTimeElapsed && ! stopBacktestIfMaxRunningHoursHasBeenReached ) ); } ! // private void removeTimerEventHandlers() ! // { ! // foreach( NewDateTimeEventHandler newDateTimeEventHandler in ! // this.timer.NewDateTime.GetInvocationList()) ! // { ! // this.timer.NewDateTime -= newDateTimeEventHandler; ! // } ! // } ! ! #region stopTheScript ! private void stopTheScript( DateTime currentDateTime ) ! { ! this.actualLastDateTime = ! ExtendedDateTime.Min( this.lastDateTime , currentDateTime ); ! this.timer.Stop(); ! // this.removeTimerEventHandlers(); ! // this.timer.NewDateTime -= ! // new NewDateTimeEventHandler( ! // this.strategyForBacktester.NewDateTimeEventHandler ); ! this.realDateTimeWhenTheBackTestIsStopped = DateTime.Now; ! this.accountReport = this.account.CreateReport( ! "" , ! 1 , currentDateTime , this.benchmark.Ticker , ! this.historicalMarketValueProvider ); ! this.accountReport.Name = this.Description; ! } ! // private void stopTheScriptIfTheCase( Object sender ) ! // { ! // DateTime currentDateTime = ! // ( ( Timer )sender ).GetCurrentDateTime(); ! // if ( this.isTimeToStop( currentDateTime ) ) ! // { ! // // either the simulation has reached the ending date or ! // // too much time elapsed since the simulation started ! // this.stopTheScript( currentDateTime ); ! // } ! // } ! #endregion stopTheScript ! ! private void notifyProgress( ! Timer timer ) { string progressMessage = "Current out of sample date:" + ! this.timer.GetCurrentDateTime().ToString() + " - " + "First date:" + this.firstDateTime.ToString() + " - " + ! "Last date:" + this.lastDateTime.ToString() + " - " + ! "Real time:" + DateTime.Now; NewMessageEventArgs newMessageEventArgs = new NewMessageEventArgs( progressMessage ); *************** *** 313,357 **** this.NewMessage( this , newMessageEventArgs ); } ! private void marketCloseEventHandler( ! Object sender , EndOfDayTimingEventArgs endOfDayTimingEventArgs ) { ! EndOfDayDateTime currentEndOfDayDateTime = ! ( ( IEndOfDayTimer )sender ).GetCurrentTime(); ! DateTime currentDateTime = currentEndOfDayDateTime.DateTime; ! if ( this.isTimeToStop( currentDateTime ) ) ! { ! // either the simulation has reached the ending date or ! // too much time elapsed since the simulation started ! this.actualLastDateTime = ! ExtendedDateTime.Min( this.lastDateTime , currentDateTime ); ! this.endOfDayTimer.Stop(); ! this.realDateTimeWhenTheBackTestIsStopped = DateTime.Now; ! this.accountReport = this.account.CreateReport( ! "" , ! 1 , currentEndOfDayDateTime , this.benchmark.Ticker , ! this.historicalQuoteProvider ); ! this.accountReport.Name = this.Description; ! ! // this.progressBarForm.Close(); ! // ObjectArchiver.Archive( this.account , ! // @"C:\Documents and Settings\Glauco\Desktop\reports\final.qP" ); ! // this.saveLog( currentTime ); ! // this.showReport( sender ); ! // WFMultiOneRankReportDebugger wFMultiOneRankReportDebugger = ! // new WFMultiOneRankReportDebugger( this.numberOfPortfolioPositions , ! // this.numberDaysForInSampleOptimization , this.benchmark ); ! // report.TransactionGrid.MouseUp += ! // new MouseEventHandler( ! // wFMultiOneRankReportDebugger.MouseClickEventHandler ); ! } ! else ! // the simulation has not reached the ending date, yet ! this.marketCloseEventHandler_notifyProgress( ! ( IEndOfDayTimer )sender ); } ! #endregion marketCloseEventHandler private void newLogItemEventHandler( object sender , ! NewLogItemEventArgs eventArgs ) { // WFLagChosenPositions wFLagChosenPositions = --- 375,395 ---- this.NewMessage( this , newMessageEventArgs ); } ! private void newDateTimeEventHandler( ! Object sender , DateTime dateTime ) { ! // EndOfDayDateTime currentEndOfDayDateTime = ! // ( ( IEndOfDayTimer )sender ).GetCurrentTime(); ! // DateTime currentDateTime = currentEndOfDayDateTime.DateTime; ! if ( this.isTimeToStop( dateTime ) ) ! this.stopTheScript( dateTime ); ! else ! this.newDateTime( sender , dateTime ); ! if ( HistoricalEndOfDayTimer.IsMarketClose( dateTime ) ) ! this.notifyProgress( ( Timer )sender ); } ! #endregion newDateTimeEventHandler private void newLogItemEventHandler( object sender , ! NewLogItemEventArgs eventArgs ) { // WFLagChosenPositions wFLagChosenPositions = |
|
From: Glauco S. <gla...@us...> - 2008-09-29 21:17:00
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/CallingReportsForRunScripts In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv15503 Modified Files: ShowReportFromFile.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: ShowReportFromFile.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/CallingReportsForRunScripts/ShowReportFromFile.cs,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** ShowReportFromFile.cs 10 Jun 2005 18:45:44 -0000 1.5 --- ShowReportFromFile.cs 29 Sep 2008 21:16:45 -0000 1.6 *************** *** 90,96 **** foreach(Object key in transactions.Keys) { ! foreach(EndOfDayTransaction transaction in (ArrayList)transactions[key]) { ! account.Add(transaction); } } --- 90,96 ---- foreach(Object key in transactions.Keys) { ! foreach(TimedTransaction timedTransaction in (ArrayList)transactions[key]) { ! account.Add(timedTransaction); } } |
|
From: Glauco S. <gla...@us...> - 2008-09-29 21:16:57
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/ArbitrageTesting/OverReactionHypothesis/DoubleOverReaction_OTC In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv15309/ArbitrageTesting/OverReactionHypothesis/DoubleOverReaction_OTC Modified Files: EndOfDayTimerHandlerDOR_OTC.cs RunDOR_OTC.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: RunDOR_OTC.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/ArbitrageTesting/OverReactionHypothesis/DoubleOverReaction_OTC/RunDOR_OTC.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** RunDOR_OTC.cs 19 Aug 2008 17:13:04 -0000 1.2 --- RunDOR_OTC.cs 29 Sep 2008 21:16:12 -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; --- 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; *************** *** 37,169 **** /// Script that implements the Double OverReaction Open To Close strategy: /// at each open, l long positions and s short positions will be open, ! /// buying and shorting, accordingly, the l tickers among the /// b best that more moves down (at open) and the s tickers among the w worst /// that more moves up (at open). ! /// For chosing the b best and w worst tickers just the /// previous close to close ratio is considered. ! /// The fundamental of the strategy should be the fact (to be verified ...) /// that overreactions may be followed by opposite overreactions. /// At each close, open positions are closed. /// </summary> ! [Serializable] ! public class RunDOR_OTC ! { ! private string scriptName; ! private string tickerGroupID; ! private string benchmark; ! private int numberOfEligibleTickers; ! private int numOfBestTickers; ! private int numOfWorstTickers; ! private int numOfTickersForBuying; ! private int numOfTickersForShortSelling; ! private DateTime startDate; ! private DateTime endDate; ! private double maxRunningHours; ! private DateTime startingTimeForScript; ! private Account account; ! private IHistoricalQuoteProvider historicalQuoteProvider; ! private IEndOfDayTimer endOfDayTimer; ! ! public RunDOR_OTC(string tickerGroupID, string benchmark, ! int numberOfEligibleTickers, int numOfBestTickers, ! int numOfWorstTickers, int numOfTickersForBuying, ! int numOfTickersForShortSelling, ! DateTime startDate, DateTime endDate, ! double maxRunningHours) ! { ! this.tickerGroupID = tickerGroupID; ! this.benchmark = benchmark; ! this.numberOfEligibleTickers = numberOfEligibleTickers; ! this.numOfBestTickers = numOfBestTickers; ! this.numOfWorstTickers = numOfWorstTickers; ! this.numOfTickersForBuying = numOfTickersForBuying; ! this.numOfTickersForShortSelling = numOfTickersForShortSelling; ! this.startDate = startDate; ! this.endDate = endDate; ! this.maxRunningHours = maxRunningHours; ! this.scriptName = "DoubleOverReaction_OTC"; ! this.historicalQuoteProvider = new HistoricalRawQuoteProvider(); ! this.endOfDayTimer = new IndexBasedEndOfDayTimer( ! new EndOfDayDateTime( this.startDate , ! EndOfDaySpecificTime.MarketOpen ) , this.benchmark ); ! } - public void Run() - { - this.startingTimeForScript = DateTime.Now; - this.account = new Account( "DoubleOverReaction_OTC" , this.endOfDayTimer , - new HistoricalEndOfDayDataStreamer( this.endOfDayTimer , - this.historicalQuoteProvider ) , - new HistoricalEndOfDayOrderExecutor( this.endOfDayTimer , - this.historicalQuoteProvider ) ); - EndOfDayTimerHandlerDOR_OTC endOfDayTimerHandler = - new EndOfDayTimerHandlerDOR_OTC(this.tickerGroupID, this.numberOfEligibleTickers, - this.numOfBestTickers, this.numOfWorstTickers, - this.numOfTickersForBuying, this.numOfTickersForShortSelling, - this.account, this.benchmark); - this.endOfDayTimer.MarketOpen += new MarketOpenEventHandler( - endOfDayTimerHandler.MarketOpenEventHandler ); ! this.endOfDayTimer.MarketClose += new MarketCloseEventHandler( ! endOfDayTimerHandler.MarketCloseEventHandler ); ! this.endOfDayTimer.MarketClose += new MarketCloseEventHandler( ! this.checkDateForReport); ! this.endOfDayTimer.OneHourAfterMarketClose += new OneHourAfterMarketCloseEventHandler( ! endOfDayTimerHandler.OneHourAfterMarketCloseEventHandler ); ! ! this.endOfDayTimer.Start(); ! } ! private void checkDateForReport(Object sender , EndOfDayTimingEventArgs endOfDayTimingEventArgs) ! { ! if(endOfDayTimingEventArgs.EndOfDayDateTime.DateTime>=this.endDate || ! 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.SaveScriptResults(); ! } ! private void checkDateForReport_createDirIfNotPresent(string dirPath) ! { ! if(!Directory.Exists(dirPath)) ! Directory.CreateDirectory(dirPath); ! } ! public void SaveScriptResults() ! { ! TimeSpan span; span = DateTime.Now.Subtract(this.startingTimeForScript); int secondsElapsed = span.Hours * 3600 + span.Minutes * 60 + span.Seconds; ! string fileName = ! "SecondsElapsed_" + secondsElapsed.ToString() + "_" + ! DateTime.Now.Hour.ToString().PadLeft(2,'0') + "_" + ! DateTime.Now.Minute.ToString().PadLeft(2,'0') + "_" + ! this.scriptName + "_From_" + this.tickerGroupID + ! "_elig_" + this.numberOfEligibleTickers + ! "_best_" + this.numOfBestTickers + ! "_worst_" + this.numOfWorstTickers + ! "_forLong_" + this.numOfTickersForBuying + ! "_forShort_" + this.numOfTickersForShortSelling; ! string dirNameWhereToSaveReports = ! System.Configuration.ConfigurationManager.AppSettings["ReportsArchive"] + ! "\\" + this.scriptName + "\\"; ! ! //default report with numIntervalDays = 1 ! AccountReport accountReport = this.account.CreateReport(fileName,1, ! this.endOfDayTimer.GetCurrentTime(), ! this.benchmark, ! new HistoricalRawQuoteProvider() ); ! // new HistoricalAdjustedQuoteProvider()); ! this.checkDateForReport_createDirIfNotPresent(dirNameWhereToSaveReports); ! ObjectArchiver.Archive(accountReport, ! dirNameWhereToSaveReports + ! fileName + ".qPr"); ! ! this.endOfDayTimer.Stop(); ! } ! } } --- 37,178 ---- /// Script that implements the Double OverReaction Open To Close strategy: /// at each open, l long positions and s short positions will be open, ! /// buying and shorting, accordingly, the l tickers among the /// b best that more moves down (at open) and the s tickers among the w worst /// that more moves up (at open). ! /// For chosing the b best and w worst tickers just the /// previous close to close ratio is considered. ! /// The fundamental of the strategy should be the fact (to be verified ...) /// that overreactions may be followed by opposite overreactions. /// At each close, open positions are closed. /// </summary> ! [Serializable] ! public class RunDOR_OTC ! { ! private string scriptName; ! private string tickerGroupID; ! private string benchmark; ! private int numberOfEligibleTickers; ! private int numOfBestTickers; ! private int numOfWorstTickers; ! private int numOfTickersForBuying; ! private int numOfTickersForShortSelling; ! private DateTime startDate; ! private DateTime endDate; ! private double maxRunningHours; ! private DateTime startingTimeForScript; ! private Account account; ! private HistoricalMarketValueProvider historicalMarketValueProvider; ! private Timer timer; + public RunDOR_OTC(string tickerGroupID, string benchmark, + int numberOfEligibleTickers, int numOfBestTickers, + int numOfWorstTickers, int numOfTickersForBuying, + int numOfTickersForShortSelling, + DateTime startDate, DateTime endDate, + double maxRunningHours) + { + this.tickerGroupID = tickerGroupID; + this.benchmark = benchmark; + this.numberOfEligibleTickers = numberOfEligibleTickers; + this.numOfBestTickers = numOfBestTickers; + this.numOfWorstTickers = numOfWorstTickers; + this.numOfTickersForBuying = numOfTickersForBuying; + this.numOfTickersForShortSelling = numOfTickersForShortSelling; + this.startDate = startDate; + this.endDate = endDate; + this.maxRunningHours = maxRunningHours; + this.scriptName = "DoubleOverReaction_OTC"; + this.historicalMarketValueProvider = new HistoricalRawQuoteProvider(); + this.timer = new IndexBasedEndOfDayTimer( + HistoricalEndOfDayTimer.GetMarketOpen( this.startDate ) , this.benchmark ); + // new EndOfDayDateTime( this.startDate , + // EndOfDaySpecificTime.MarketOpen ) , this.benchmark ); + } ! public void Run() ! { ! this.startingTimeForScript = DateTime.Now; ! this.account = new Account( "DoubleOverReaction_OTC" , this.timer , ! new HistoricalEndOfDayDataStreamer( this.timer , ! this.historicalMarketValueProvider ) , ! new HistoricalEndOfDayOrderExecutor( this.timer , ! this.historicalMarketValueProvider ) ); ! EndOfDayTimerHandlerDOR_OTC endOfDayTimerHandler = ! new EndOfDayTimerHandlerDOR_OTC(this.tickerGroupID, this.numberOfEligibleTickers, ! this.numOfBestTickers, this.numOfWorstTickers, ! this.numOfTickersForBuying, this.numOfTickersForShortSelling, ! this.account, this.benchmark); ! ! this.timer.NewDateTime += ! new NewDateTimeEventHandler( endOfDayTimerHandler.NewDateTimeEventHandler ); ! ! // this.timer.MarketOpen += new MarketOpenEventHandler( ! // endOfDayTimerHandler.MarketOpenEventHandler ); ! // ! // this.timer.MarketClose += new MarketCloseEventHandler( ! // endOfDayTimerHandler.MarketCloseEventHandler ); ! this.timer.NewDateTime += new NewDateTimeEventHandler( ! this.checkDateForReport); ! // this.timer.OneHourAfterMarketClose += new OneHourAfterMarketCloseEventHandler( ! // endOfDayTimerHandler.OneHourAfterMarketCloseEventHandler ); ! ! this.timer.Start(); ! } ! private void checkDateForReport( ! Object sender , DateTime dateTime) ! { ! if ( HistoricalEndOfDayTimer.IsMarketClose( dateTime ) ) ! { ! if( dateTime >= this.endDate || ! 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.SaveScriptResults(); ! } ! } ! private void checkDateForReport_createDirIfNotPresent(string dirPath) ! { ! if(!Directory.Exists(dirPath)) ! Directory.CreateDirectory(dirPath); ! } ! public void SaveScriptResults() ! { ! TimeSpan span; span = DateTime.Now.Subtract(this.startingTimeForScript); int secondsElapsed = span.Hours * 3600 + span.Minutes * 60 + span.Seconds; ! string fileName = ! "SecondsElapsed_" + secondsElapsed.ToString() + "_" + ! DateTime.Now.Hour.ToString().PadLeft(2,'0') + "_" + ! DateTime.Now.Minute.ToString().PadLeft(2,'0') + "_" + ! this.scriptName + "_From_" + this.tickerGroupID + ! "_elig_" + this.numberOfEligibleTickers + ! "_best_" + this.numOfBestTickers + ! "_worst_" + this.numOfWorstTickers + ! "_forLong_" + this.numOfTickersForBuying + ! "_forShort_" + this.numOfTickersForShortSelling; ! string dirNameWhereToSaveReports = ! System.Configuration.ConfigurationManager.AppSettings["ReportsArchive"] + ! "\\" + this.scriptName + "\\"; ! ! //default report with numIntervalDays = 1 ! AccountReport accountReport = this.account.CreateReport(fileName,1, ! this.timer.GetCurrentDateTime(), ! this.benchmark, ! new HistoricalRawQuoteProvider() ); ! // new HistoricalAdjustedQuoteProvider()); ! this.checkDateForReport_createDirIfNotPresent(dirNameWhereToSaveReports); ! ObjectArchiver.Archive(accountReport, ! dirNameWhereToSaveReports + ! fileName + ".qPr"); ! ! this.timer.Stop(); ! } ! } } Index: EndOfDayTimerHandlerDOR_OTC.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/ArbitrageTesting/OverReactionHypothesis/DoubleOverReaction_OTC/EndOfDayTimerHandlerDOR_OTC.cs,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** EndOfDayTimerHandlerDOR_OTC.cs 19 Aug 2008 17:11:27 -0000 1.4 --- EndOfDayTimerHandlerDOR_OTC.cs 29 Sep 2008 21:16:12 -0000 1.5 *************** *** 31,35 **** using QuantProject.Business.Strategies; using QuantProject.Data; ! using QuantProject.Data.DataProviders; using QuantProject.Data.Selectors; --- 31,35 ---- using QuantProject.Business.Strategies; using QuantProject.Data; ! using QuantProject.Data.DataProviders.Quotes; using QuantProject.Data.Selectors; *************** *** 82,86 **** } ! #region MarketOpenEventHandler private void addOrderForTicker(string[] tickers, --- 82,86 ---- } ! #region marketOpenEventHandler private void addOrderForTicker(string[] tickers, *************** *** 123,137 **** private double setChosenTickers_getGainOrLossFromPreviousClose(string signedTicker) { ! IndexBasedEndOfDayTimer currentTimer = (IndexBasedEndOfDayTimer)this.account.EndOfDayTimer; ! ExtendedDateTime nowAtOpen = ! new ExtendedDateTime(currentTimer.GetCurrentTime().DateTime, ! BarComponent.Open); ! ExtendedDateTime previousClose = ! new ExtendedDateTime(currentTimer.GetPreviousDateTime(), ! BarComponent.Close); double currentValueAtOpen = ! HistoricalDataProvider.GetAdjustedMarketValue(SignedTicker.GetTicker(signedTicker), nowAtOpen); double previousValueAtClose = ! HistoricalDataProvider.GetAdjustedMarketValue(SignedTicker.GetTicker(signedTicker), previousClose); return (currentValueAtOpen - previousValueAtClose) / previousValueAtClose; --- 123,143 ---- private double setChosenTickers_getGainOrLossFromPreviousClose(string signedTicker) { ! IndexBasedEndOfDayTimer currentTimer = (IndexBasedEndOfDayTimer)this.account.Timer; ! DateTime nowAtOpen = ! HistoricalEndOfDayTimer.GetMarketOpen( currentTimer.GetCurrentDateTime() ); ! // new ExtendedDateTime(currentTimer.GetCurrentTime().DateTime, ! // BarComponent.Open); ! DateTime previousClose = ! HistoricalEndOfDayTimer.GetMarketClose( currentTimer.GetPreviousDateTime() ); ! // new ExtendedDateTime(currentTimer.GetPreviousDateTime(), ! // BarComponent.Close); double currentValueAtOpen = ! HistoricalQuotesProvider.GetAdjustedMarketValue( ! SignedTicker.GetTicker(signedTicker), ! nowAtOpen , MarketStatusSwitch.Open ); double previousValueAtClose = ! HistoricalQuotesProvider.GetAdjustedMarketValue( ! SignedTicker.GetTicker(signedTicker), ! previousClose , MarketStatusSwitch.Close ); return (currentValueAtOpen - previousValueAtClose) / previousValueAtClose; *************** *** 201,206 **** /// <param name="sender"></param> /// <param name="eventArgs"></param> ! public void MarketOpenEventHandler( ! Object sender , EndOfDayTimingEventArgs endOfDayTimingEventArgs ) { if(this.orders.Count == 0 && this.account.Transactions.Count == 0) --- 207,212 ---- /// <param name="sender"></param> /// <param name="eventArgs"></param> ! private void marketOpenEventHandler( ! Object sender , DateTime dateTime ) { if(this.orders.Count == 0 && this.account.Transactions.Count == 0) *************** *** 219,223 **** #endregion ! #region MarketCloseEventHandler private void closePosition( string ticker ) --- 225,229 ---- #endregion ! #region marketCloseEventHandler private void closePosition( string ticker ) *************** *** 235,240 **** } ! public void MarketCloseEventHandler( ! Object sender , EndOfDayTimingEventArgs endOfDayTimingEventArgs ) { this.closePositions(); --- 241,246 ---- } ! public void marketCloseEventHandler( ! Object sender , DateTime dateTime ) { this.closePositions(); *************** *** 243,247 **** #endregion ! #region OneHourAfterMarketCloseEventHandler private void oneHourAfterMarketCloseEventHandler_clear() --- 249,253 ---- #endregion ! #region oneHourAfterMarketCloseEventHandler private void oneHourAfterMarketCloseEventHandler_clear() *************** *** 261,269 **** /// <param name="sender"></param> /// <param name="eventArgs"></param> ! public void OneHourAfterMarketCloseEventHandler( ! Object sender , EndOfDayTimingEventArgs endOfDayTimingEventArgs ) { this.oneHourAfterMarketCloseEventHandler_clear(); ! DateTime currentDate = endOfDayTimingEventArgs.EndOfDayDateTime.DateTime; SelectorByGroup temporizedGroup = new SelectorByGroup(this.tickerGroupID, currentDate); --- 267,275 ---- /// <param name="sender"></param> /// <param name="eventArgs"></param> ! public void oneHourAfterMarketCloseEventHandler( ! Object sender , DateTime dateTime ) { this.oneHourAfterMarketCloseEventHandler_clear(); ! DateTime currentDate = dateTime; SelectorByGroup temporizedGroup = new SelectorByGroup(this.tickerGroupID, currentDate); *************** *** 350,353 **** --- 356,371 ---- } #endregion + + public virtual void NewDateTimeEventHandler( + Object sender , DateTime dateTime ) + { + if ( HistoricalEndOfDayTimer.IsMarketOpen( dateTime ) ) + this.marketOpenEventHandler( sender , dateTime ); + if ( HistoricalEndOfDayTimer.IsMarketClose( dateTime ) ) + this.marketCloseEventHandler( sender , dateTime ); + if ( HistoricalEndOfDayTimer.IsOneHourAfterMarketClose( dateTime ) ) + this.oneHourAfterMarketCloseEventHandler( sender , dateTime ); + } + } } |
|
From: Glauco S. <gla...@us...> - 2008-09-29 21:16:53
|
Update of /cvsroot/quantproject/QuantProject/b4_Business/a2_Strategies/returnsManagement/time/selectors In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv15371/returnsManagement/time/selectors Modified Files: EvenIntervalsSelector.cs FixedLengthTwoPhasesIntervalsSelector.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: EvenIntervalsSelector.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b4_Business/a2_Strategies/returnsManagement/time/selectors/EvenIntervalsSelector.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** EvenIntervalsSelector.cs 17 May 2008 18:02:24 -0000 1.1 --- EvenIntervalsSelector.cs 29 Sep 2008 21:16:19 -0000 1.2 *************** *** 39,42 **** --- 39,43 ---- /// (first, third, ...) are skipped instead /// </summary> + [Serializable] public class EvenIntervalsSelector : OddIntervalsSelector { *************** *** 69,77 **** public override ReturnInterval GetFirstInterval( ! EndOfDayDateTime startingEndOfDayDateTime ) { ReturnInterval firstInterval = this.fixedLengthTwoPhasesIntervalsSelector.GetFirstInterval( ! startingEndOfDayDateTime ); ReturnIntervals returnIntervalsWithTheFirstIntervalOnly = new ReturnIntervals( firstInterval ); --- 70,78 ---- public override ReturnInterval GetFirstInterval( ! DateTime startingDateTime ) { ReturnInterval firstInterval = this.fixedLengthTwoPhasesIntervalsSelector.GetFirstInterval( ! startingDateTime ); ReturnIntervals returnIntervalsWithTheFirstIntervalOnly = new ReturnIntervals( firstInterval ); Index: FixedLengthTwoPhasesIntervalsSelector.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b4_Business/a2_Strategies/returnsManagement/time/selectors/FixedLengthTwoPhasesIntervalsSelector.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** FixedLengthTwoPhasesIntervalsSelector.cs 27 Feb 2008 22:08:19 -0000 1.2 --- FixedLengthTwoPhasesIntervalsSelector.cs 29 Sep 2008 21:16:19 -0000 1.3 *************** *** 37,40 **** --- 37,41 ---- /// exchanged) /// </summary> + [Serializable] public class FixedLengthTwoPhasesIntervalsSelector : IIntervalsSelector { *************** *** 78,101 **** return benchmarkTimeStepsForCurrentPhase; } ! private EndOfDayDateTime getNextReturnIntervalEnd( ! EndOfDayDateTime returnIntervalBegin , int benchmarkTimeStepsForCurrentPhase ) { ! EndOfDayDateTime currentEndOfDayDateTime = returnIntervalBegin; for ( int i = 0 ; i < benchmarkTimeStepsForCurrentPhase ; i++ ) { ! currentEndOfDayDateTime = ! this.benchmark.GetTimeStep( currentEndOfDayDateTime ).End; } ! return currentEndOfDayDateTime; } ! private EndOfDayDateTime getIntervalEnd( ! EndOfDayDateTime nextReturnIntervalBegin , int numIntervalsAlreadyDone ) { int benchmarkTimeStepsForCurrentPhase = this.getBenchmarkTimeStepsForCurrentPhase( numIntervalsAlreadyDone ); ! EndOfDayDateTime nextReturnIntervalEnd = this.getNextReturnIntervalEnd( nextReturnIntervalBegin , benchmarkTimeStepsForCurrentPhase ); --- 79,102 ---- return benchmarkTimeStepsForCurrentPhase; } ! private DateTime getNextReturnIntervalEnd( ! DateTime returnIntervalBegin , int benchmarkTimeStepsForCurrentPhase ) { ! DateTime currentDateTime = returnIntervalBegin; for ( int i = 0 ; i < benchmarkTimeStepsForCurrentPhase ; i++ ) { ! currentDateTime = ! this.benchmark.GetTimeStep( currentDateTime ).End; } ! return currentDateTime; } ! private DateTime getIntervalEnd( ! DateTime nextReturnIntervalBegin , int numIntervalsAlreadyDone ) { int benchmarkTimeStepsForCurrentPhase = this.getBenchmarkTimeStepsForCurrentPhase( numIntervalsAlreadyDone ); ! DateTime nextReturnIntervalEnd = this.getNextReturnIntervalEnd( nextReturnIntervalBegin , benchmarkTimeStepsForCurrentPhase ); *************** *** 106,112 **** public ReturnInterval GetNextInterval( ReturnIntervals returnIntervals ) { ! EndOfDayDateTime nextReturnIntervalBegin = returnIntervals[ returnIntervals.Count - 1 ].End; ! EndOfDayDateTime nextReturnIntervalEnd = this.getIntervalEnd( nextReturnIntervalBegin , returnIntervals.Count ); --- 107,113 ---- public ReturnInterval GetNextInterval( ReturnIntervals returnIntervals ) { ! DateTime nextReturnIntervalBegin = returnIntervals[ returnIntervals.Count - 1 ].End; ! DateTime nextReturnIntervalEnd = this.getIntervalEnd( nextReturnIntervalBegin , returnIntervals.Count ); *************** *** 116,121 **** } #region GetFirstInterval ! private EndOfDayDateTime getFirstIntervalBegin( ! EndOfDayDateTime startingEndOfDayDateTime ) { // qui!!!! fai un ciclo while non exchanged (trova --- 117,122 ---- } #region GetFirstInterval ! private DateTime getFirstIntervalBegin( ! DateTime startingDateTime ) { // qui!!!! fai un ciclo while non exchanged (trova *************** *** 125,131 **** // benchmark e' // scambiato) ! EndOfDayDateTime firstIntervalBegin = this.benchmark.GetThisOrNextMarketStatusSwitch( ! startingEndOfDayDateTime ); // EndOfDayDateTime firstIntervalBegin = // startingEndOfDayDateTime; --- 126,132 ---- // benchmark e' // scambiato) ! DateTime firstIntervalBegin = this.benchmark.GetThisOrNextMarketStatusSwitch( ! startingDateTime ); // EndOfDayDateTime firstIntervalBegin = // startingEndOfDayDateTime; *************** *** 141,149 **** } public ReturnInterval GetFirstInterval( ! EndOfDayDateTime startingEndOfDayDateTime ) { ! EndOfDayDateTime firstIntervalBegin = ! this.getFirstIntervalBegin( startingEndOfDayDateTime ); ! EndOfDayDateTime firstIntervalEnd = this.getIntervalEnd( firstIntervalBegin , 0 ); ReturnInterval nextInterval = new ReturnInterval( --- 142,150 ---- } public ReturnInterval GetFirstInterval( ! DateTime startingDateTime ) { ! DateTime firstIntervalBegin = ! this.getFirstIntervalBegin( startingDateTime ); ! DateTime firstIntervalEnd = this.getIntervalEnd( firstIntervalBegin , 0 ); ReturnInterval nextInterval = new ReturnInterval( |
|
From: Glauco S. <gla...@us...> - 2008-09-29 21:16:48
|
Update of /cvsroot/quantproject/QuantProject/b4_Business/a2_Strategies/InSample In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv15371/InSample Modified Files: GeneticChooser.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: GeneticChooser.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b4_Business/a2_Strategies/InSample/GeneticChooser.cs,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** GeneticChooser.cs 9 Mar 2008 21:42:21 -0000 1.9 --- GeneticChooser.cs 29 Sep 2008 21:16:19 -0000 1.10 *************** *** 43,46 **** --- 43,47 ---- /// in sample optimization /// </summary> + [Serializable] public abstract class GeneticChooser : IInSampleChooser { *************** *** 59,63 **** protected IDecoderForTestingPositions decoderForTestingPositions; protected IFitnessEvaluator fitnessEvaluator; ! protected IHistoricalQuoteProvider historicalQuoteProvider; protected IGenomeManager genomeManager; protected double crossoverRate; --- 60,64 ---- protected IDecoderForTestingPositions decoderForTestingPositions; protected IFitnessEvaluator fitnessEvaluator; ! protected HistoricalMarketValueProvider historicalMarketValueProvider; protected IGenomeManager genomeManager; protected double crossoverRate; *************** *** 96,100 **** IDecoderForTestingPositions decoderForTestingPositions , IFitnessEvaluator fitnessEvaluator , ! IHistoricalQuoteProvider historicalQuoteProvider , double crossoverRate , double mutationRate , double elitismRate , int populationSizeForGeneticOptimizer , --- 97,101 ---- IDecoderForTestingPositions decoderForTestingPositions , IFitnessEvaluator fitnessEvaluator , ! HistoricalMarketValueProvider historicalMarketValueProvider , double crossoverRate , double mutationRate , double elitismRate , int populationSizeForGeneticOptimizer , *************** *** 107,111 **** this.decoderForTestingPositions = decoderForTestingPositions; this.fitnessEvaluator = fitnessEvaluator; ! this.historicalQuoteProvider = historicalQuoteProvider; this.crossoverRate = crossoverRate; this.mutationRate = mutationRate; --- 108,112 ---- this.decoderForTestingPositions = decoderForTestingPositions; this.fitnessEvaluator = fitnessEvaluator; ! this.historicalMarketValueProvider = historicalMarketValueProvider; this.crossoverRate = crossoverRate; this.mutationRate = mutationRate; |
|
From: Glauco S. <gla...@us...> - 2008-09-29 21:16:45
|
Update of /cvsroot/quantproject/QuantProject/b4_Business/a2_Strategies/Eligibles In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv15371/Eligibles Modified Files: EligibleTickers.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: EligibleTickers.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b4_Business/a2_Strategies/Eligibles/EligibleTickers.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** EligibleTickers.cs 6 Feb 2008 23:01:28 -0000 1.2 --- EligibleTickers.cs 29 Sep 2008 21:16:18 -0000 1.3 *************** *** 29,32 **** --- 29,33 ---- /// Strongly typed collection of tickers /// </summary> + [Serializable] public class EligibleTickers : System.Collections.CollectionBase { |
|
From: Glauco S. <gla...@us...> - 2008-09-29 21:16:44
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/ArbitrageTesting/OverReactionHypothesis/DoubleOverReaction_WeekEndBounce In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv15309/ArbitrageTesting/OverReactionHypothesis/DoubleOverReaction_WeekEndBounce Modified Files: EndOfDayTimerHandlerDOR_WeekEndBounce.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: EndOfDayTimerHandlerDOR_WeekEndBounce.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/ArbitrageTesting/OverReactionHypothesis/DoubleOverReaction_WeekEndBounce/EndOfDayTimerHandlerDOR_WeekEndBounce.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** EndOfDayTimerHandlerDOR_WeekEndBounce.cs 19 Aug 2008 17:11:28 -0000 1.2 --- EndOfDayTimerHandlerDOR_WeekEndBounce.cs 29 Sep 2008 21:16:12 -0000 1.3 *************** *** 31,35 **** using QuantProject.Business.Strategies; using QuantProject.Data; ! using QuantProject.Data.DataProviders; using QuantProject.Data.Selectors; --- 31,35 ---- using QuantProject.Business.Strategies; using QuantProject.Data; ! using QuantProject.Data.DataProviders.Quotes; using QuantProject.Data.Selectors; *************** *** 43,52 **** /// </summary> [Serializable] ! public class EndOfDayTimerHandlerDOR_WeekEndBounce { private string tickerGroupID; private int numberOfEligibleTickers; private string benchmark; ! private Account account; private int numOfWorstTickers; private int numOfBestTickers; --- 43,52 ---- /// </summary> [Serializable] ! public class EndOfDayTimerHandlerDOR_WeekEndBounce : EndOfDayStrategy { private string tickerGroupID; private int numberOfEligibleTickers; private string benchmark; ! // private Account account; private int numOfWorstTickers; private int numOfBestTickers; *************** *** 143,157 **** private double setChosenTickers_getGainOrLossFromPreviousClose(string signedTicker) { ! IndexBasedEndOfDayTimer currentTimer = (IndexBasedEndOfDayTimer)this.account.EndOfDayTimer; ! ExtendedDateTime nowAtOpen = ! new ExtendedDateTime(currentTimer.GetCurrentTime().DateTime, ! BarComponent.Open); ! ExtendedDateTime previousClose = ! new ExtendedDateTime(currentTimer.GetPreviousDateTime(), ! BarComponent.Close); double currentValueAtOpen = ! HistoricalDataProvider.GetAdjustedMarketValue(SignedTicker.GetTicker(signedTicker), nowAtOpen); double previousValueAtClose = ! HistoricalDataProvider.GetAdjustedMarketValue(SignedTicker.GetTicker(signedTicker), previousClose); return (currentValueAtOpen - previousValueAtClose) / previousValueAtClose; --- 143,163 ---- private double setChosenTickers_getGainOrLossFromPreviousClose(string signedTicker) { ! IndexBasedEndOfDayTimer currentTimer = (IndexBasedEndOfDayTimer)this.account.Timer; ! DateTime nowAtOpen = ! HistoricalEndOfDayTimer.GetMarketOpen( currentTimer.GetCurrentDateTime() ); ! // new ExtendedDateTime(currentTimer.GetCurrentTime().DateTime, ! // BarComponent.Open); ! DateTime previousClose = ! HistoricalEndOfDayTimer.GetMarketClose( currentTimer.GetPreviousDateTime() ); ! // new ExtendedDateTime(currentTimer.GetPreviousDateTime(), ! // BarComponent.Close); double currentValueAtOpen = ! HistoricalQuotesProvider.GetAdjustedMarketValue( ! SignedTicker.GetTicker(signedTicker), ! nowAtOpen , MarketStatusSwitch.Open ); double previousValueAtClose = ! HistoricalQuotesProvider.GetAdjustedMarketValue( ! SignedTicker.GetTicker(signedTicker), ! previousClose , MarketStatusSwitch.Close ); return (currentValueAtOpen - previousValueAtClose) / previousValueAtClose; *************** *** 221,226 **** /// <param name="sender"></param> /// <param name="eventArgs"></param> ! public void MarketOpenEventHandler( ! Object sender , EndOfDayTimingEventArgs endOfDayTimingEventArgs ) { if(this.orders.Count == 0 && this.account.Transactions.Count == 0) --- 227,232 ---- /// <param name="sender"></param> /// <param name="eventArgs"></param> ! protected override void marketOpenEventHandler( ! Object sender , DateTime dateTime ) { if(this.orders.Count == 0 && this.account.Transactions.Count == 0) *************** *** 228,235 **** if ( (this.account.Portfolio.Count == 0 && ! endOfDayTimingEventArgs.EndOfDayDateTime.DateTime.DayOfWeek == DayOfWeek.Monday) || (this.account.Portfolio.Count == 0 && ! endOfDayTimingEventArgs.EndOfDayDateTime.DateTime.DayOfWeek == DayOfWeek.Tuesday) ) { --- 234,241 ---- if ( (this.account.Portfolio.Count == 0 && ! dateTime.DayOfWeek == DayOfWeek.Monday) || (this.account.Portfolio.Count == 0 && ! dateTime.DayOfWeek == DayOfWeek.Tuesday) ) { *************** *** 244,252 **** this.openPositions(this.chosenTickers); } ! else if (endOfDayTimingEventArgs.EndOfDayDateTime.DateTime.DayOfWeek == DayOfWeek.Wednesday || ! endOfDayTimingEventArgs.EndOfDayDateTime.DateTime.DayOfWeek == DayOfWeek.Thursday || ! endOfDayTimingEventArgs.EndOfDayDateTime.DateTime.DayOfWeek == DayOfWeek.Friday) this.closePositions(); --- 250,258 ---- this.openPositions(this.chosenTickers); } ! else if (dateTime.DayOfWeek == DayOfWeek.Wednesday || ! dateTime.DayOfWeek == DayOfWeek.Thursday || ! dateTime.DayOfWeek == DayOfWeek.Friday) this.closePositions(); *************** *** 255,265 **** #endregion ! public void MarketCloseEventHandler( ! Object sender , EndOfDayTimingEventArgs endOfDayTimingEventArgs ) { } ! #region OneHourAfterMarketCloseEventHandler private void oneHourAfterMarketCloseEventHandler_clear() --- 261,271 ---- #endregion ! protected override void marketCloseEventHandler( ! Object sender , DateTime dateTime ) { } ! #region oneHourAfterMarketCloseEventHandler private void oneHourAfterMarketCloseEventHandler_clear() *************** *** 279,292 **** /// <param name="sender"></param> /// <param name="eventArgs"></param> ! public void OneHourAfterMarketCloseEventHandler( ! Object sender , EndOfDayTimingEventArgs endOfDayTimingEventArgs ) { this.oneHourAfterMarketCloseEventHandler_clear(); ! if ( endOfDayTimingEventArgs.EndOfDayDateTime.DateTime.DayOfWeek == DayOfWeek.Friday && ( (IndexBasedEndOfDayTimer)sender ).CurrentDateArrayPosition >= this.lengthInDaysForPerformance ) { ! DateTime currentDate = endOfDayTimingEventArgs.EndOfDayDateTime.DateTime; int currentDateArrayPositionInTimer = ((IndexBasedEndOfDayTimer)sender).CurrentDateArrayPosition; SelectorByGroup temporizedGroup = new SelectorByGroup(this.tickerGroupID, --- 285,298 ---- /// <param name="sender"></param> /// <param name="eventArgs"></param> ! protected override void oneHourAfterMarketCloseEventHandler( ! Object sender , DateTime dateTime ) { this.oneHourAfterMarketCloseEventHandler_clear(); ! if ( dateTime.DayOfWeek == DayOfWeek.Friday && ( (IndexBasedEndOfDayTimer)sender ).CurrentDateArrayPosition >= this.lengthInDaysForPerformance ) { ! DateTime currentDate = dateTime; int currentDateArrayPositionInTimer = ((IndexBasedEndOfDayTimer)sender).CurrentDateArrayPosition; SelectorByGroup temporizedGroup = new SelectorByGroup(this.tickerGroupID, |