[Quantproject-developers] QuantProject/b7_Scripts MyTradingSystem.cs, 1.2, 1.3
Brought to you by:
glauco_1
|
From: Glauco S. <gla...@us...> - 2008-09-29 21:16:43
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv15309 Modified Files: MyTradingSystem.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: MyTradingSystem.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/MyTradingSystem.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** MyTradingSystem.cs 29 Nov 2004 16:13:55 -0000 1.2 --- MyTradingSystem.cs 29 Sep 2008 21:16:12 -0000 1.3 *************** *** 3,7 **** MyTradingSystem.cs ! Copyright (C) 2003 Glauco Siliprandi --- 3,7 ---- MyTradingSystem.cs ! Copyright (C) 2003 Glauco Siliprandi *************** *** 19,26 **** 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; using QuantProject.ADT; using QuantProject.ADT.Histories; --- 19,27 ---- 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; + using QuantProject.ADT; using QuantProject.ADT.Histories; *************** *** 30,33 **** --- 31,35 ---- using QuantProject.Business.Strategies; using QuantProject.Business.Timing; + using QuantProject.Data.DataProviders.Quotes; namespace QuantProject.Scripts *************** *** 38,87 **** public class MyTradingSystem : TradingSystem { ! private History microsoftOpenHistory; ! private History microsoftOpenHistorySMA; ! public MyTradingSystem() ! { ! } ! public override void InitializeData() ! { ! Parameter parameter = (Parameter) this.Parameters[ "SMAdays" ]; ! microsoftOpenHistory = QuoteCache.GetOpenHistory( "MSFT" ); ! microsoftOpenHistorySMA = microsoftOpenHistory.GetSimpleMovingAverage( (int) parameter.Value ); ! } ! public override Signals GetSignals( ExtendedDateTime extendedDateTime ) ! { ! Signals signals = new Signals(); ! Signal signal = new Signal(); ! if ( microsoftOpenHistory.Cross( microsoftOpenHistorySMA , ! extendedDateTime.DateTime ) && ! ( Convert.ToDouble(microsoftOpenHistorySMA.GetValue( extendedDateTime.DateTime )) > ! ( Convert.ToDouble(microsoftOpenHistory.GetValue( extendedDateTime.DateTime )) * ! ( 100 + Convert.ToInt32( ! ((Parameter)this.Parameters[ "CrossPercentage" ]).Value ) ) / 100 ) ) ) ! { ! signal.Add( new Order( OrderType.MarketBuy , new Instrument( "MSFT" ) , 1 , ! new EndOfDayDateTime( new Instrument( "MSFT" ).GetNextMarketDay( extendedDateTime.DateTime ) , ! EndOfDaySpecificTime.MarketOpen ) ) ); ! signals.Add( signal ); ! } ! else ! { ! if ( microsoftOpenHistorySMA.Cross( microsoftOpenHistory , ! extendedDateTime.DateTime ) && ! ( Convert.ToDouble(microsoftOpenHistorySMA.GetValue( extendedDateTime.DateTime )) > ! ( Convert.ToDouble(microsoftOpenHistory.GetValue( extendedDateTime.DateTime )) * ! ( 100 + Convert.ToInt32( ((Parameter)this.Parameters[ "CrossPercentage" ]).Value ) ) / 100 ) ) ) ! { ! signal.Add( new Order( OrderType.MarketSell , new Instrument( "MSFT" ) , 1 , ! new EndOfDayDateTime( new Instrument( "MSFT" ).GetNextMarketDay( extendedDateTime.DateTime ) , ! EndOfDaySpecificTime.MarketOpen ) ) ); ! signals.Add( signal ); ! } ! } ! return signals; ! } ! } } --- 40,99 ---- public class MyTradingSystem : TradingSystem { ! private History microsoftOpenHistory; ! private History microsoftOpenHistorySMA; ! public MyTradingSystem() ! { ! } ! public override void InitializeData() ! { ! Parameter parameter = (Parameter) this.Parameters[ "SMAdays" ]; ! microsoftOpenHistory = HistoricalQuotesProvider.GetOpenHistory( "MSFT" ); ! microsoftOpenHistorySMA = microsoftOpenHistory.GetSimpleMovingAverage( (int) parameter.Value ); ! } ! public override Signals GetSignals( DateTime dateTime ) ! { ! Signals signals = new Signals(); ! Signal signal = new Signal(); ! if ( microsoftOpenHistory.Cross( microsoftOpenHistorySMA , ! dateTime ) && ! ( Convert.ToDouble(microsoftOpenHistorySMA.GetValue( dateTime )) > ! ( Convert.ToDouble(microsoftOpenHistory.GetValue( dateTime )) * ! ( 100 + Convert.ToInt32( ! ((Parameter)this.Parameters[ "CrossPercentage" ]).Value ) ) / 100 ) ) ) ! { ! signal.Add( new Order( ! OrderType.MarketBuy , ! new Instrument( "MSFT" ) , ! 1 , ! HistoricalEndOfDayTimer.GetMarketOpen( ! new Instrument( "MSFT" ).GetNextMarketDay( dateTime ) ) ) ); ! // new EndOfDayDateTime( new Instrument( "MSFT" ).GetNextMarketDay( dateTime.DateTime ) , ! // EndOfDaySpecificTime.MarketOpen ) ) ); ! signals.Add( signal ); ! } ! else ! { ! if ( microsoftOpenHistorySMA.Cross( microsoftOpenHistory , ! dateTime ) && ! ( Convert.ToDouble(microsoftOpenHistorySMA.GetValue( dateTime )) > ! ( Convert.ToDouble(microsoftOpenHistory.GetValue( dateTime )) * ! ( 100 + Convert.ToInt32( ((Parameter)this.Parameters[ "CrossPercentage" ]).Value ) ) / 100 ) ) ) ! { ! signal.Add( new Order( ! OrderType.MarketSell , ! new Instrument( "MSFT" ) , ! 1 , ! HistoricalEndOfDayTimer.GetMarketOpen( ! new Instrument( "MSFT" ).GetNextMarketDay( dateTime ) ) ) ); ! // new EndOfDayDateTime( new Instrument( "MSFT" ).GetNextMarketDay( dateTime.DateTime ) , ! // EndOfDaySpecificTime.MarketOpen ) ) ); ! signals.Add( signal ); ! } ! } ! return signals; ! } ! } } |