[Quantproject-developers] QuantProject/b7_Scripts/WalkForwardTesting/LinearCombination CloseToOpen
Brought to you by:
glauco_1
|
From: Glauco S. <gla...@us...> - 2008-09-29 21:19:01
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/LinearCombination In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv16751/LinearCombination Modified Files: CloseToOpenDailyStrategy.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: CloseToOpenDailyStrategy.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/LinearCombination/CloseToOpenDailyStrategy.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** CloseToOpenDailyStrategy.cs 12 Mar 2008 22:09:04 -0000 1.3 --- CloseToOpenDailyStrategy.cs 29 Sep 2008 21:18:26 -0000 1.4 *************** *** 3,7 **** CloseToOpenDailyStrategy.cs ! Copyright (C) 2003 Marco Milletti --- 3,7 ---- CloseToOpenDailyStrategy.cs ! Copyright (C) 2003 Marco Milletti *************** *** 19,23 **** along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ! */ using System; --- 19,23 ---- along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ! */ using System; *************** *** 36,40 **** /// </summary> [Serializable] ! public class CloseToOpenDailyStrategy : IEndOfDayStrategy { private Account account; --- 36,40 ---- /// </summary> [Serializable] ! public class CloseToOpenDailyStrategy : IStrategy { private Account account; *************** *** 48,52 **** public CloseToOpenDailyStrategy( Account account , ! WeightedPositions weightedPositions) { this.account = account; --- 48,52 ---- public CloseToOpenDailyStrategy( Account account , ! WeightedPositions weightedPositions) { this.account = account; *************** *** 54,79 **** } ! public void MarketOpenEventHandler( ! Object sender , EndOfDayTimingEventArgs endOfDayTimingEventArgs ) { AccountManager.ClosePositions(this.account); } ! public void FiveMinutesBeforeMarketCloseEventHandler( Object sender , ! EndOfDayTimingEventArgs endOfDayTimingEventArgs) { } ! public void MarketCloseEventHandler( Object sender , ! EndOfDayTimingEventArgs endOfDayTimingEventArgs) { ! if ( ( this.account.CashAmount == 0 ) && ! ( this.account.Transactions.Count == 0 ) ) ! // cash has not been added yet ! this.account.AddCash( 15000 ); ! AccountManager.OpenPositions(this.weightedPositions, this.account); } ! public void OneHourAfterMarketCloseEventHandler( Object sender , ! EndOfDayTimingEventArgs endOfDayTimingEventArgs) { } } } --- 54,90 ---- } ! private void marketOpenEventHandler( ! Object sender , DateTime dateTime ) { AccountManager.ClosePositions(this.account); } ! private void fiveMinutesBeforeMarketCloseEventHandler( Object sender , ! DateTime dateTime) { } ! private void marketCloseEventHandler( Object sender , ! DateTime dateTime) { ! if ( ( this.account.CashAmount == 0 ) && ! ( this.account.Transactions.Count == 0 ) ) ! // cash has not been added yet ! this.account.AddCash( 15000 ); ! AccountManager.OpenPositions(this.weightedPositions, this.account); } ! private void oneHourAfterMarketCloseEventHandler( Object sender , ! DateTime dateTime) { } + + 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 ); + } } } |