quantproject-developers Mailing List for QuantProject (Page 127)
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...> - 2004-11-29 15:05:39
|
Update of /cvsroot/quantproject/QuantProject/b4_Business/a1_Financial/a3_Ordering In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv874 Added Files: IOrderExecutor.cs Log Message: Order manager interface --- NEW FILE: IOrderExecutor.cs --- /* QuantProject - Quantitative Finance Library Order.cs Copyright (C) 2003 Glauco Siliprandi This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License 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 QuantProject.Business.Financial.Accounting.Transactions; namespace QuantProject.Business.Financial.Ordering { public delegate void OrderFilledEventHandler( Object sender , OrderFilledEventArgs eventArgs ); /// <summary> /// Order manager interface /// </summary> public interface IOrderExecutor { void Execute( Order order ); event OrderFilledEventHandler OrderFilled; } } |
|
From: Glauco S. <gla...@us...> - 2004-11-29 14:52:02
|
Update of /cvsroot/quantproject/QuantProject/b4_Business/a1_Financial/a3_Ordering In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30316 Added Files: HistoricalEndOfDayOrderExecutor.cs Log Message: Simulates historical order executions/rejections for end of day simulation --- NEW FILE: HistoricalEndOfDayOrderExecutor.cs --- /* QuantProject - Quantitative Finance Library HistoricalEndOfDayOrderExecutor.cs Copyright (C) 2003 Glauco Siliprandi This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License 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.Data.DataProviders; using QuantProject.Business.Financial.Accounting; using QuantProject.Business.Financial.Accounting.Transactions; using QuantProject.Business.Timing; namespace QuantProject.Business.Financial.Ordering { /// <summary> /// Simulates historical order executions/rejections for end of day simulation /// </summary> public class HistoricalEndOfDayOrderExecutor : IOrderExecutor { private IEndOfDayTimer timer; public HistoricalEndOfDayOrderExecutor( IEndOfDayTimer timer ) { this.timer = timer; } public event OrderFilledEventHandler OrderFilled; // Tries to execute the order public void Execute( Order order ) { double instrumentPrice = HistoricalDataProvider.GetMarketValue( order.Instrument.Key , this.timer.GetCurrentTime().DateTime , this.timer.GetCurrentTime().GetNearestBarComponent() ); EndOfDayTransaction endOfDayTransaction = new EndOfDayTransaction( TimedTransaction.GetTransactionType( order.Type ) , order.Instrument , order.Quantity , instrumentPrice , this.timer.GetCurrentTime() ); OrderFilled( this , new OrderFilledEventArgs( order , endOfDayTransaction ) ); } } } |
|
From: Glauco S. <gla...@us...> - 2004-11-29 14:50:08
|
Update of /cvsroot/quantproject/QuantProject/b4_Business/a1_Financial/a2_Accounting/Transactions In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29948 Added Files: EndOfDayTransaction.cs Log Message: Transaction to be used with end of day strategies --- NEW FILE: EndOfDayTransaction.cs --- /* QuantProject - Quantitative Finance Library TimedTransaction.cs Copyright (C) 2003 Glauco Siliprandi This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License 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 QuantProject.ADT; using QuantProject.Business.Financial.Instruments; using QuantProject.Business.Financial.Ordering; using QuantProject.Business.Timing; namespace QuantProject.Business.Financial.Accounting.Transactions { /// <summary> /// Transaction to be used with end of day strategies /// </summary> [Serializable] public class EndOfDayTransaction : Transaction { private EndOfDayDateTime endOfDayDateTime; public EndOfDayDateTime EndOfDayDateTime { get { return endOfDayDateTime; } } public EndOfDayTransaction( TransactionType transactionType , Double transactionAmount , EndOfDayDateTime endOfDayDateTime ) : base( transactionType , transactionAmount ) { //base( transactionType , transactionAmount ); this.endOfDayDateTime = endOfDayDateTime; } public EndOfDayTransaction( TransactionType transactionType , Instrument instrument , long quantity , double instrumentPrice , EndOfDayDateTime endOfDayDateTime ) : base( transactionType , instrument , quantity , instrumentPrice ) { this.endOfDayDateTime = endOfDayDateTime; } static public TransactionType GetTransactionType( OrderType orderType ) { TransactionType returnValue; switch ( orderType ) { case OrderType.LimitBuy: returnValue = TransactionType.BuyLong; break; case OrderType.MarketBuy: returnValue = TransactionType.BuyLong; break; case OrderType.LimitCover: returnValue = TransactionType.Cover; break; case OrderType.MarketCover: returnValue = TransactionType.Cover; break; case OrderType.LimitSell: returnValue = TransactionType.Sell; break; case OrderType.MarketSell: returnValue = TransactionType.Sell; break; case OrderType.LimitSellShort: returnValue = TransactionType.SellShort; break; case OrderType.MarketSellShort: returnValue = TransactionType.SellShort; break; //this line should never be reached! default: returnValue = TransactionType.AddCash; break; } return returnValue; } public override string ToString() { return base.ToString() + "\n DateTime: " + this.endOfDayDateTime.ToString(); } } } |
|
From: Glauco S. <gla...@us...> - 2004-11-29 14:49:33
|
Update of /cvsroot/quantproject/QuantProject/b4_Business/a1_Financial/a2_Accounting/Transactions In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29831 Added Files: TransactionHistory.cs Log Message: Transaction history --- NEW FILE: TransactionHistory.cs --- /* QuantProject - Quantitative Finance Library TransactionHistory.cs Copyright (C) 2003 Glauco Siliprandi This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License 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.Histories; namespace QuantProject.Business.Financial.Accounting.Transactions { /// <summary> /// Transaction history /// </summary> [Serializable] public class TransactionHistory : History { public TransactionHistory() { // // TODO: Add constructor logic here // } public double TotalAddedCash { get { double totalAddedCash = 0; foreach ( ArrayList arrayList in this.Values ) foreach ( Transaction transaction in arrayList ) if ( transaction.Type == TransactionType.AddCash ) totalAddedCash += transaction.Amount; return totalAddedCash; } } public double TotalWithdrawn { get { double totalWithdrawn = 0; foreach ( ArrayList arrayList in this.Values ) foreach ( Transaction transaction in arrayList ) if ( transaction.Type == TransactionType.Withdraw ) totalWithdrawn += transaction.Amount; return totalWithdrawn; } } public void Add( TimedTransaction transaction ) { base.MultiAdd( transaction.ExtendedDateTime.DateTime , transaction ); } public void Add( EndOfDayTransaction transaction ) { base.MultiAdd( transaction.EndOfDayDateTime.DateTime , transaction ); } public override string ToString() { string toString = ""; foreach ( ArrayList arrayList in this.Values ) foreach ( Transaction transaction in arrayList ) toString += transaction.ToString(); return toString; } } } |
|
From: Glauco S. <gla...@us...> - 2004-11-29 14:47:56
|
Update of /cvsroot/quantproject/QuantProject/b4_Business/a1_Financial/a2_Accounting/Transactions In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29439/Transactions Log Message: Directory /cvsroot/quantproject/QuantProject/b4_Business/a1_Financial/a2_Accounting/Transactions added to the repository |
|
From: Glauco S. <gla...@us...> - 2004-11-29 14:45:16
|
Update of /cvsroot/quantproject/QuantProject/b4_Business/a07_DataProviders In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28719 Added Files: HistoricalEndOfDayDataStreamer.cs Log Message: IDataStreamer implementation using end of day historical data --- NEW FILE: HistoricalEndOfDayDataStreamer.cs --- /* QuantProject - Quantitative Finance Library HistoricalEndOfDayDataStreamer.cs Copyright (C) 2003 Glauco Siliprandi This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License 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.Business.Timing; using QuantProject.Data.DataProviders; namespace QuantProject.Business.Timing { /// <summary> /// IDataStreamer implementation using end of day historical data /// </summary> public class HistoricalEndOfDayDataStreamer : IDataStreamer { private Hashtable tickers; private IEndOfDayTimer endOfDayTimer; private EndOfDayDateTime startDateTime; private EndOfDayDateTime endDateTime; public EndOfDayDateTime StartDateTime { get { return this.startDateTime; } set { this.startDateTime = value; } } public EndOfDayDateTime EndDateTime { get { return this.endDateTime; } set { this.endDateTime = value; } } public HistoricalEndOfDayDataStreamer( IEndOfDayTimer endOfDayTimer ) { this.endOfDayTimer = endOfDayTimer; this.endOfDayTimer.MarketOpen += new MarketOpenEventHandler( this.marketOpenEventHandler ); this.tickers = new Hashtable(); } /// <summary> /// Returns the current bid for the given ticker /// </summary> /// <param name="ticker"></param> /// <returns></returns> public double GetCurrentBid( string ticker ) { return HistoricalDataProvider.GetMarketValue( ticker , this.endOfDayTimer.GetCurrentTime().GetNearestExtendedDateTime() ); } /// <summary> /// Returns the current ask for the given ticker /// </summary> /// <param name="ticker"></param> /// <returns></returns> public double GetCurrentAsk( string ticker ) { return HistoricalDataProvider.GetMarketValue( ticker , this.endOfDayTimer.GetCurrentTime().GetNearestExtendedDateTime() ); } /// <summary> /// Add a ticker whose quotes are to be monitored /// </summary> /// <param name="ticker"></param> public void Add( string ticker ) { if ( !this.tickers.Contains( ticker ) ) this.tickers.Add( ticker , 1 ); } public event NewQuoteEventHandler NewQuote; // /// <summary> // /// Starts the time walking simulation // /// </summary> // public void GoSimulate() // { // this.timer = new Timer( this.startDateTime , this.endDateTime ); // timer.NewExtendedDateTime += new NewExtendedDateTimeHandler( // this.newExtendedDateTimeHandler ); // timer.Start(); // } private void marketOpenEventHandler( Object sender , EndOfDayTimingEventArgs eventArgs ) { if ( this.tickers.Count > 0 ) { // the data streamer is monitoring some ticker Hashtable quotes = HistoricalDataProvider.GetQuotes( this.tickers , this.endOfDayTimer.GetCurrentTime().GetNearestExtendedDateTime() ); foreach ( Quote quote in quotes ) this.NewQuote( this , new NewQuoteEventArgs( quote ) ); } } } } |
|
From: Glauco S. <gla...@us...> - 2004-11-29 14:44:04
|
Update of /cvsroot/quantproject/QuantProject/b4_Business/a07_DataProviders In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28349/a07_DataProviders Log Message: Directory /cvsroot/quantproject/QuantProject/b4_Business/a07_DataProviders added to the repository |
|
From: Glauco S. <gla...@us...> - 2004-11-29 14:43:40
|
Update of /cvsroot/quantproject/QuantProject/b4_Business/a05_Timing In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28265 Added Files: HistoricalEndOfDayTimer.cs Log Message: IDataStreamer implementation using historical data --- NEW FILE: HistoricalEndOfDayTimer.cs --- /* QuantProject - Quantitative Finance Library HistoricalDataStreamer.cs Copyright (C) 2003 Glauco Siliprandi This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License 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; namespace QuantProject.Business.Timing { /// <summary> /// IDataStreamer implementation using historical data /// </summary> public class HistoricalEndOfDayTimer : IEndOfDayTimer { private bool isActive; // true iff the timer is started and not stopped private Hashtable tickers; private EndOfDayDateTime currentTime; private EndOfDayDateTime startDateTime; // private EndOfDayDateTime endDateTime; public EndOfDayDateTime StartDateTime { get { return this.startDateTime; } set { this.startDateTime = value; } } // public EndOfDayDateTime EndDateTime // { // get { return this.endDateTime; } // set { this.endDateTime = value; } // } public event MarketOpenEventHandler MarketOpen; public event FiveMinutesBeforeMarketCloseEventHandler FiveMinutesBeforeMarketClose; public event MarketCloseEventHandler MarketClose; public event OneHourAfterMarketCloseEventHandler OneHourAfterMarketClose; public HistoricalEndOfDayTimer( EndOfDayDateTime startDateTime ) { this.startDateTime = startDateTime; // this.endDateTime = EndDateTime; this.tickers = new Hashtable(); } /// <summary> /// Starts the time walking simulation /// </summary> public void Start() { this.isActive = true; this.currentTime = this.startDateTime; while ( this.isActive ) { if ( this.MarketOpen != null ) this.MarketOpen( this , new EndOfDayTimingEventArgs( this.currentTime ) ); if ( this.FiveMinutesBeforeMarketClose != null ) this.FiveMinutesBeforeMarketClose( this , new EndOfDayTimingEventArgs( this.currentTime ) ); if ( this.MarketClose != null ) this.MarketClose( this , new EndOfDayTimingEventArgs( this.currentTime ) ); if ( this.OneHourAfterMarketClose != null ) this.OneHourAfterMarketClose( this , new EndOfDayTimingEventArgs( this.currentTime ) ); this.currentTime.MoveNext(); } } public EndOfDayDateTime GetCurrentTime() { return this.currentTime; } /// <summary> /// Stops the timer /// </summary> public void Stop() { this.isActive = false; } } } |
|
From: Glauco S. <gla...@us...> - 2004-11-29 14:41:23
|
Update of /cvsroot/quantproject/QuantProject/b4_Business/a05_Timing In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27559 Added Files: IEndOfDayTimer.cs Log Message: Interface to be implemented by timers for end of day simulations --- NEW FILE: IEndOfDayTimer.cs --- /* QuantProject - Quantitative Finance Library IEndOfDayTimer.cs Copyright (C) 2003 Glauco Siliprandi This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License 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 QuantProject.ADT; namespace QuantProject.Business.Timing { public delegate void MarketOpenEventHandler( Object sender , EndOfDayTimingEventArgs eventArgs ); public delegate void FiveMinutesBeforeMarketCloseEventHandler( Object sender , EndOfDayTimingEventArgs eventArgs ); public delegate void MarketCloseEventHandler( Object sender , EndOfDayTimingEventArgs eventArgs ); public delegate void OneHourAfterMarketCloseEventHandler( Object sender , EndOfDayTimingEventArgs eventArgs ); /// <summary> /// Interface to be implemented by timers for end of day simulations /// </summary> public interface IEndOfDayTimer { event MarketOpenEventHandler MarketOpen; event FiveMinutesBeforeMarketCloseEventHandler FiveMinutesBeforeMarketClose; event MarketCloseEventHandler MarketClose; event OneHourAfterMarketCloseEventHandler OneHourAfterMarketClose; EndOfDayDateTime GetCurrentTime(); /// <summary> /// The timer is instructed to begin to fire timing events /// </summary> void Start(); void Stop(); } } |
|
From: Glauco S. <gla...@us...> - 2004-11-29 14:40:20
|
Update of /cvsroot/quantproject/QuantProject/b4_Business/a05_Timing In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27276 Added Files: EndOfDayTimingEventArgs.cs Log Message: Specific daily moments to be used with end of day strategies --- NEW FILE: EndOfDayTimingEventArgs.cs --- /* QuantProject - Quantitative Finance Library EndOfDayNewTimeEventArgs.cs Copyright (C) 2003 Glauco Siliprandi This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License 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 QuantProject.ADT; namespace QuantProject.Business.Timing { /// <summary> /// Argument for end of day new time events /// </summary> public class EndOfDayTimingEventArgs { private EndOfDayDateTime endOfDayDateTime; public EndOfDayDateTime EndOfDayDateTime { get { return this.endOfDayDateTime; } } public EndOfDayTimingEventArgs( EndOfDayDateTime endOfDayDateTime ) { this.endOfDayDateTime = endOfDayDateTime; } } } |
|
From: Glauco S. <gla...@us...> - 2004-11-29 14:39:24
|
Update of /cvsroot/quantproject/QuantProject/b4_Business/a05_Timing In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26974 Added Files: EndOfDaySpecificTime.cs Log Message: Specific daily moments to be used with end of day strategies --- NEW FILE: EndOfDaySpecificTime.cs --- /* QuantProject - Quantitative Finance Library EndOfDaySpecificTime.cs Copyright (C) 2003 Glauco Siliprandi This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License 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 QuantProject.ADT; namespace QuantProject.Business.Timing { /// <summary> /// Specific daily moments to be used with end of day strategies /// </summary> public enum EndOfDaySpecificTime { MarketOpen, FiveMinutesBeforeMarketClose, MarketClose, OneHourAfterMarketClose } } |
|
From: Glauco S. <gla...@us...> - 2004-11-29 14:38:30
|
Update of /cvsroot/quantproject/QuantProject/b4_Business/a05_Timing In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26652 Added Files: EndOfDayDateTime.cs Log Message: Date time to be used with end of day strategies --- NEW FILE: EndOfDayDateTime.cs --- /* QuantProject - Quantitative Finance Library EndOfDayDateTime.cs Copyright (C) 2003 Glauco Siliprandi This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License 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 QuantProject.ADT; namespace QuantProject.Business.Timing { /// <summary> /// Date time to be used with end of day strategies /// </summary> public class EndOfDayDateTime : IComparable { private DateTime dateTime; private EndOfDaySpecificTime endOfDaySpecificTime; public DateTime DateTime { get { return dateTime; } set { dateTime = value; } } public EndOfDaySpecificTime EndOfDaySpecificTime { get { return endOfDaySpecificTime; } set { endOfDaySpecificTime = value; } } public EndOfDayDateTime( DateTime dateTime , EndOfDaySpecificTime endOfDaySpecificTime ) { this.dateTime = dateTime; this.endOfDaySpecificTime = endOfDaySpecificTime; } public BarComponent GetNearestBarComponent() { BarComponent returnValue = BarComponent.Close; switch ( this.endOfDaySpecificTime ) { case EndOfDaySpecificTime.FiveMinutesBeforeMarketClose: returnValue = BarComponent.Close; break; case EndOfDaySpecificTime.MarketClose: returnValue = BarComponent.Close; break; case EndOfDaySpecificTime.MarketOpen: returnValue = BarComponent.Open; break; case EndOfDaySpecificTime.OneHourAfterMarketClose: returnValue = BarComponent.Close; break; } return returnValue; } public ExtendedDateTime GetNearestExtendedDateTime() { return new ExtendedDateTime( this.dateTime , this.GetNearestBarComponent() ); } public int CompareTo( object endOfDayDateTime ) { int returnValue = -1; EndOfDayDateTime toBeCompared = (EndOfDayDateTime)( endOfDayDateTime ); if ( ( this.DateTime == toBeCompared.DateTime ) && ( this.endOfDaySpecificTime == toBeCompared.endOfDaySpecificTime ) ) // this is the same as the end of day date time to be compared returnValue = 0; if ( ( this.DateTime > toBeCompared.DateTime ) || ( ( this.DateTime == toBeCompared.DateTime ) && ( this.endOfDaySpecificTime > toBeCompared.endOfDaySpecificTime ) ) ) // this is the greater than the end of day date time to be compared returnValue = 1; return returnValue; } #region MoveNext private EndOfDaySpecificTime getNextSpecificTime( ) { EndOfDaySpecificTime returnValue; Type type = EndOfDaySpecificTime.GetType(); Array values = EndOfDaySpecificTime.GetValues( type ); returnValue = ( EndOfDaySpecificTime)values.GetValue( 0 ); for ( int i = 0 ; i < values.Length - 1 ; i++ ) if ( this.endOfDaySpecificTime == ( EndOfDaySpecificTime)values.GetValue( i ) ) returnValue = ( EndOfDaySpecificTime)values.GetValue( i + 1 ); return returnValue; } /// <summary> /// Moves to the next end of day date time /// </summary> public void MoveNext() { EndOfDaySpecificTime nextSpecificTime = this.getNextSpecificTime(); if ( nextSpecificTime < this.endOfDaySpecificTime ) { // the current end of day specific time is the last end of day specific time in the day this.dateTime = this.dateTime.AddDays( 1 ); } this.endOfDaySpecificTime = nextSpecificTime; } #endregion } } |
|
From: Glauco S. <gla...@us...> - 2004-11-29 14:37:35
|
Update of /cvsroot/quantproject/QuantProject/b4_Business/a05_Timing In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26234/a05_Timing Log Message: Directory /cvsroot/quantproject/QuantProject/b4_Business/a05_Timing added to the repository |
|
From: Glauco S. <gla...@us...> - 2004-11-29 14:36:53
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/SimpleTesting/OneRank In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26040 Added Files: OneRank.cs Log Message: Performs the OneRank strategy on a single ticker --- NEW FILE: OneRank.cs --- /* QuantProject - Quantitative Finance Library OneRank.cs Copyright (C) 2003 Glauco Siliprandi This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License 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 QuantProject.Data.DataProviders; using QuantProject.Business.Financial.Accounting; using QuantProject.Business.Financial.Instruments; using QuantProject.Business.Financial.Ordering; using QuantProject.Business.Timing; namespace QuantProject.Scripts.SimpleTesting { /// <summary> /// Performs the OneRank strategy on a single ticker /// </summary> public class OneRank { private Account account; private DateTime lastDateTime; public void fiveMinutesBeforeMarketCloseEventHandler( Object sender , EndOfDayTimingEventArgs endOfDayTimingEventArgs ) { long sharesToBeBought; double todayMarketValueAtClose = this.account.DataStreamer.GetCurrentBid( this.account.Key ); EndOfDayDateTime yesterdayAtClose = new EndOfDayDateTime( this.account.EndOfDayTimer.GetCurrentTime().DateTime.AddHours( - 1 ) , EndOfDaySpecificTime.MarketClose ); double yesterdayMarketValueAtClose = HistoricalDataProvider.GetMarketValue( this.account.Key , yesterdayAtClose.GetNearestExtendedDateTime() ); if ( ( todayMarketValueAtClose > yesterdayMarketValueAtClose ) && ( !this.account.Contains( this.account.Key ) ) ) { // today close is higher than yesterday close and no position // is kept in portfolio, yet sharesToBeBought = Convert.ToInt64( Math.Floor( this.account.CashAmount / this.account.DataStreamer.GetCurrentAsk( this.account.Key ) ) ); this.account.AddOrder( new Order( OrderType.MarketBuy , new Instrument( this.account.Key ) , sharesToBeBought ) ); } if ( ( todayMarketValueAtClose < yesterdayMarketValueAtClose ) && ( this.account.Contains( this.account.Key ) ) ) this.account.ClosePosition( this.account.Key ); if ( this.account.EndOfDayTimer.GetCurrentTime().DateTime > this.lastDateTime ) this.account.EndOfDayTimer.Stop(); } /// <summary> /// Runs the OneRank strategy /// </summary> /// <param name="account">Account with which to run the strategy</param> /// <param name="lastDateTime">Date to stop the strategy</param> public OneRank( Account account , DateTime lastDateTime ) { this.account = account; this.lastDateTime = lastDateTime; this.account.EndOfDayTimer.FiveMinutesBeforeMarketClose += new FiveMinutesBeforeMarketCloseEventHandler( this.fiveMinutesBeforeMarketCloseEventHandler ); this.account.EndOfDayTimer.Start(); } } } |
|
From: Glauco S. <gla...@us...> - 2004-11-29 14:35:49
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/SimpleTesting/OneRank In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25717 Added Files: EndOfDayOneRank.cs Log Message: One rank strategy on a single ticker --- NEW FILE: EndOfDayOneRank.cs --- /* QuantProject - Quantitative Finance Library OneRank.cs Copyright (C) 2003 Glauco Siliprandi This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License 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 QuantProject.ADT; using QuantProject.Business.Financial.Instruments; using QuantProject.Business.Financial.Accounting; using QuantProject.Business.Financial.Ordering; using QuantProject.Business.Timing; using QuantProject.Data.DataProviders; namespace QuantProject.Scripts.SimpleTesting { /// <summary> /// One rank strategy on a single ticker /// </summary> public class EndOfDayOneRank { private string ticker; private Account account; private void fiveMinutesBeforeMarketCloseHandler( Object sender , EndOfDayTimingEventArgs eventArgs ) { if ( this.account.GetMarketValue( this.ticker ) <= HistoricalDataProvider.GetMarketValue( this.ticker , this.account.EndOfDayTimer.GetCurrentTime().DateTime.AddDays( - 1 ) , BarComponent.Close ) ) { // today's closing value is lower or equal than yesterday's closing value if ( this.account.Portfolio.Contains( this.ticker ) ) this.account.ClosePosition( this.ticker ); } else { // today's closing value is higher than yesterday's closing value if ( !this.account.Portfolio.Contains( this.ticker ) ) { int maxBuyableQuantity = Convert.ToInt16( Math.Floor( this.account.CashAmount / this.account.GetMarketValue( this.ticker ))); this.account.AddOrder( new Order( OrderType.MarketBuy , new Instrument( ticker ) , maxBuyableQuantity ) ); } } } public EndOfDayOneRank( string ticker , Account account ) { this.ticker = ticker; this.account = account; this.account.AddCash( 10000 ); this.account.EndOfDayTimer.FiveMinutesBeforeMarketClose += new FiveMinutesBeforeMarketCloseEventHandler( this.fiveMinutesBeforeMarketCloseHandler ); } } } |
|
From: Glauco S. <gla...@us...> - 2004-11-29 14:34:36
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/WalkForwardOneRank In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25243 Added Files: ProgressBarForm.cs Log Message: Form to show the progress bars for the script --- NEW FILE: ProgressBarForm.cs --- using System; using System.Drawing; using System.Collections; using System.ComponentModel; using System.Windows.Forms; namespace QuantProject.Scripts.WalkForwardTesting.WalkForwardOneRank { /// <summary> /// Summary description for ProgressBarWindow. /// </summary> public class ProgressBarForm : System.Windows.Forms.Form { private System.Windows.Forms.ProgressBar progressBarInSample; private System.Windows.Forms.ProgressBar progressBarOutOfSample; private System.Windows.Forms.Label labelOutOfSample; private System.Windows.Forms.Label labelInSample; /// <summary> /// Required designer variable. /// </summary> private System.ComponentModel.Container components = null; public ProgressBar ProgressBarOutOfSample { get { return this.progressBarOutOfSample; } set { this.progressBarOutOfSample = value; } } public ProgressBar ProgressBarInSample { get { return this.progressBarInSample; } set { this.progressBarInSample = value; } } public ProgressBarForm() { // // Required for Windows Form Designer support // InitializeComponent(); // // TODO: Add any constructor code after InitializeComponent call // this.progressBarOutOfSample.Maximum = 100; this.progressBarInSample.Maximum = 100; } /// <summary> /// Clean up any resources being used. /// </summary> protected override void Dispose( bool disposing ) { if( disposing ) { if(components != null) { components.Dispose(); } } base.Dispose( disposing ); } #region Windows Form Designer generated code /// <summary> /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// </summary> private void InitializeComponent() { this.progressBarInSample = new System.Windows.Forms.ProgressBar(); this.progressBarOutOfSample = new System.Windows.Forms.ProgressBar(); this.labelOutOfSample = new System.Windows.Forms.Label(); this.labelInSample = new System.Windows.Forms.Label(); this.SuspendLayout(); // // progressBarInSample // this.progressBarInSample.Location = new System.Drawing.Point(120, 24); this.progressBarInSample.Name = "progressBarInSample"; this.progressBarInSample.Size = new System.Drawing.Size(200, 16); this.progressBarInSample.TabIndex = 0; // // progressBarOutOfSample // this.progressBarOutOfSample.Location = new System.Drawing.Point(120, 72); this.progressBarOutOfSample.Name = "progressBarOutOfSample"; this.progressBarOutOfSample.Size = new System.Drawing.Size(200, 16); this.progressBarOutOfSample.TabIndex = 1; // // labelOutOfSample // this.labelOutOfSample.Location = new System.Drawing.Point(32, 72); this.labelOutOfSample.Name = "labelOutOfSample"; this.labelOutOfSample.Size = new System.Drawing.Size(80, 16); this.labelOutOfSample.TabIndex = 2; this.labelOutOfSample.Text = "Out of Sample:"; this.labelOutOfSample.TextAlign = System.Drawing.ContentAlignment.MiddleRight; this.labelOutOfSample.Click += new System.EventHandler(this.label1_Click); // // labelInSample // this.labelInSample.Location = new System.Drawing.Point(40, 24); this.labelInSample.Name = "labelInSample"; this.labelInSample.Size = new System.Drawing.Size(72, 16); this.labelInSample.TabIndex = 3; this.labelInSample.Text = "In Sample:"; this.labelInSample.TextAlign = System.Drawing.ContentAlignment.MiddleRight; // // ProgressBarWindow // this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); this.ClientSize = new System.Drawing.Size(424, 117); this.Controls.AddRange(new System.Windows.Forms.Control[] { this.labelInSample, this.labelOutOfSample, this.progressBarOutOfSample, this.progressBarInSample}); this.Name = "ProgressBarWindow"; this.Text = "ProgressBarWindow"; this.ResumeLayout(false); } #endregion private void label1_Click(object sender, System.EventArgs e) { } } } |
|
From: Glauco S. <gla...@us...> - 2004-11-29 14:33:28
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/WalkForwardOneRank In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25013 Added Files: EligibleTickers.cs Log Message: Selects the tickers among which best performers will be searched --- NEW FILE: EligibleTickers.cs --- /* QuantProject - Quantitative Finance Library EligibleTickers.cs Copyright (C) 2003 Glauco Siliprandi This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License 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 System.Data; using QuantProject.Data.Selectors; namespace QuantProject.Scripts.WalkForwardTesting.WalkForwardOneRank { /// <summary> /// Selects the tickers to among which best performers will be searched /// </summary> public class EligibleTickers : Hashtable { private int numberEligibleTickersToBeChosen; private int numDaysToComputeLiquidity = 10; public EligibleTickers( int numberEligibleTickersToBeChosen ) { this.numberEligibleTickersToBeChosen = numberEligibleTickersToBeChosen; } #region SetTickers private void setTickers_build( DateTime dateTime ) { TickerSelector tickerSelector = new TickerSelector( SelectionType.Liquidity , false , "Test" , dateTime.AddDays( - this.numDaysToComputeLiquidity ) , dateTime , this.numberEligibleTickersToBeChosen ); DataTable selectedTickers = tickerSelector.GetTableOfSelectedTickers(); foreach ( DataRow dataRow in selectedTickers.Rows ) this.Add( dataRow[ "tiTicker" ].ToString() , dataRow[ "tiTicker" ].ToString() ); } /// <summary> /// Populates the collection of eligible tickers /// </summary> /// <param name="dateTime"></param> public void SetTickers( DateTime dateTime ) { this.Clear(); setTickers_build( dateTime ); } #endregion } } |
|
From: Glauco S. <gla...@us...> - 2004-11-29 14:32:19
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/WalkForwardOneRank In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24659 Added Files: ComparableAccount.cs Log Message: An account with a custom GetFitnessValue function --- NEW FILE: ComparableAccount.cs --- /* QuantProject - Quantitative Finance Library ComparableAccount.cs Copyright (C) 2003 Glauco Siliprandi This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License 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 QuantProject.Business.Financial.Accounting; using QuantProject.Business.Financial.Accounting.Reporting; namespace QuantProject.Scripts.WalkForwardTesting.WalkForwardOneRank { /// <summary> /// Summary description for ComparableAccount. /// </summary> public class ComparableAccount : Account { private double maxAcceptableDrawDown = 0.3; private AccountReport accountReport; public AccountReport Report { get { return this.accountReport; } set { this.accountReport = value; } } public double Goodness { get { return this.goodness(); } } public ComparableAccount() { // // TODO: Add constructor logic here // } private double goodness() { double returnValue; if ( this.accountReport.Summary.MaxEquityDrawDown >= this.maxAcceptableDrawDown ) returnValue = Double.MinValue; else // max draw down is acceptable returnValue = this.accountReport.Summary.TotalPnl / this.accountReport.Summary.BuyAndHoldPercentageReturn; return returnValue; } } } |
|
From: Glauco S. <gla...@us...> - 2004-11-29 14:30:00
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/WalkForwardOneRank In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23959 Added Files: ChosenTickers.cs Log Message: The collection of the chosen tickers, among the best performing ones --- NEW FILE: ChosenTickers.cs --- /* QuantProject - Quantitative Finance Library ChosenTickers.cs Copyright (C) 2003 Glauco Siliprandi This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License 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; namespace QuantProject.Scripts.WalkForwardTesting.WalkForwardOneRank { /// <summary> /// The collection of the chosen tickers, among the best performing ones /// </summary> public class ChosenTickers : Hashtable { private int numberTickersToBeChosen; public ChosenTickers( int numberTickersToBeChosen ) { this.numberTickersToBeChosen = numberTickersToBeChosen; } #region SetTickers private void setTickers_build( BestPerformingTickers bestPerformingTickers ) { SortedList sortedList = new SortedList(); foreach ( string ticker in bestPerformingTickers.Keys ) sortedList.Add( ( ( ComparableAccount )bestPerformingTickers[ ticker ]).Goodness , ticker ); for ( int n=0; n<=this.numberTickersToBeChosen ; n++ ) this.Add( sortedList.GetByIndex( n ) , 1 ); } /// <summary> /// Populates the collection of eligible tickers /// </summary> /// <param name="dateTime"></param> public void SetTickers( BestPerformingTickers bestPerformingTickers ) { this.Clear(); this.setTickers_build( bestPerformingTickers ); } #endregion } } |
|
From: Glauco S. <gla...@us...> - 2004-11-29 14:29:07
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/WalkForwardOneRank In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23699 Added Files: BestPerformingTickers.cs Log Message: The collection of best performing tickers, among the eligible ones --- NEW FILE: BestPerformingTickers.cs --- /* QuantProject - Quantitative Finance Library BestPerformingTickers.cs Copyright (C) 2003 Glauco Siliprandi This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License 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.Business.Financial.Accounting; using QuantProject.Business.Financial.Ordering; using QuantProject.Business.Timing; using QuantProject.Data.DataProviders; using QuantProject.Scripts.SimpleTesting; namespace QuantProject.Scripts.WalkForwardTesting.WalkForwardOneRank { /// <summary> /// The collection of best performing tickers, among the eligible ones /// </summary> public class BestPerformingTickers : Hashtable,IProgressNotifier { private int numberBestPerformingTickers; private int numberDaysForPerformanceCalculation; private long calculatedTickers = 0; private ArrayList eligibleAccounts; private DateTime lastUpdate; public DateTime LastUpdate { get { return this.lastUpdate; } } public BestPerformingTickers( int numberBestPerformingTickers , int numberDaysForPerformanceCalculation ) { this.numberBestPerformingTickers = numberBestPerformingTickers; this.numberDaysForPerformanceCalculation = numberDaysForPerformanceCalculation; this.eligibleAccounts = new ArrayList(); } public event NewProgressEventHandler NewProgress; #region SetTickers private void setTickers_build_addAccount( string ticker , DateTime dateTime ) { HistoricalEndOfDayTimer historicalEndOfDayTimer = new HistoricalEndOfDayTimer( new EndOfDayDateTime( dateTime.AddYears( -1 ).AddDays( -1 ) , EndOfDaySpecificTime.FiveMinutesBeforeMarketClose ) ); Account account = new Account( ticker , historicalEndOfDayTimer , new HistoricalEndOfDayDataStreamer( historicalEndOfDayTimer ) , new HistoricalEndOfDayOrderExecutor( historicalEndOfDayTimer ) ); OneRank oneRank = new OneRank( account , dateTime.AddDays( this.numberDaysForPerformanceCalculation ) ); account.Key = ticker; this.eligibleAccounts.Add( account ); } private void setTickers_build( EligibleTickers eligibleTickers , DateTime dateTime ) { foreach ( string ticker in eligibleTickers.Keys ) { setTickers_build_addAccount( ticker , dateTime ); this.calculatedTickers++; if ( Math.Floor( this.calculatedTickers / eligibleAccounts.Count * 100 ) > Math.Floor( ( this.calculatedTickers - 1 ) / eligibleAccounts.Count * 100 ) ) // a new time percentage point has been elapsed this.NewProgress( this , new NewProgressEventArgs( Convert.ToInt32( Math.Floor( this.calculatedTickers / eligibleAccounts.Count * 100 ) ) , 100 ) ); } this.eligibleAccounts.Sort(); for ( int index=0 ; index < this.numberBestPerformingTickers ; index++ ) this.Add( ((Account)this.eligibleAccounts[ index ]).Key , this.eligibleAccounts[ index ] ); } /// <summary> /// Populates the collection of the best performing tickers /// </summary> /// <param name="dateTime"></param> public void SetTickers( EligibleTickers eligibleTickers , DateTime dateTime ) { this.NewProgress( this , new NewProgressEventArgs( 0 , 100 ) ); this.Clear(); this.setTickers_build( eligibleTickers , dateTime ); this.lastUpdate = dateTime; } #endregion } } |
|
From: Glauco S. <gla...@us...> - 2004-11-29 14:28:02
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/WalkForwardOneRank In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23436 Added Files: EndOfDayTimerHandler.cs Log Message: Implements OneHourAfterMarketCloseEventHandler and TwoMinutesBeforeMarketCloseEventHandler. This is the core strategy. --- NEW FILE: EndOfDayTimerHandler.cs --- /* QuantProject - Quantitative Finance Library TimerHandler.cs Copyright (C) 2003 Glauco Siliprandi This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License 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.Business.Financial.Accounting; using QuantProject.Business.Financial.Instruments; using QuantProject.Business.Financial.Ordering; using QuantProject.Business.Timing; using QuantProject.Data.DataProviders; namespace QuantProject.Scripts.WalkForwardTesting.WalkForwardOneRank { public delegate void InSampleNewProgressEventHandler( Object sender , NewProgressEventArgs eventArgs ); /// <summary> /// Implements OneHourAfterMarketCloseEventHandler and TwoMinutesBeforeMarketCloseEventHandler. /// This is the core strategy! /// </summary> public class EndOfDayTimerHandler { private EligibleTickers eligibleTickers; private BestPerformingTickers bestPerformingTickers; private ChosenTickers chosenTickers; private int numberEligibleTickers; private int numberBestPeformingTickers; private int numberOfTickersToBeChosen; private int inSampleWindowDays; private int outOfSampleWindowDays; private Account account; public event InSampleNewProgressEventHandler InSampleNewProgress; public int NumberEligibleTickers { get { return this.numberEligibleTickers; } } public int NumberBestPeformingTickers { get { return this.numberBestPeformingTickers; } } public Account Account { get { return this.account; } } /// <summary> /// /// </summary> /// <param name="numberEligibleTickers">number of tickers to be chosen with the first selection: /// the best performers will be chosen among these first selected instruments</param> /// <param name="numberBestPeformingTickers">number of instruments to be chosen, as the best /// performers, among the eligible tickers</param> /// <param name="numberOfTickersToBeChosen">number of instruments to be chosen, /// among the best performers</param> /// <param name="windowDays">number of days between two consecutive /// best performing ticker calculation</param> public EndOfDayTimerHandler( int numberEligibleTickers , int numberBestPeformingTickers , int numberOfTickersToBeChosen , int inSampleWindowDays , int outOfSampleWindowDays , Account account ) { this.numberEligibleTickers = numberEligibleTickers; this.numberBestPeformingTickers = numberBestPeformingTickers; this.numberOfTickersToBeChosen = numberOfTickersToBeChosen; this.inSampleWindowDays = inSampleWindowDays; this.outOfSampleWindowDays = outOfSampleWindowDays; this.account = account; this.eligibleTickers = new EligibleTickers( numberEligibleTickers ); this.bestPerformingTickers = new BestPerformingTickers( numberBestPeformingTickers , this.inSampleWindowDays ); this.bestPerformingTickers.NewProgress += new NewProgressEventHandler( this.bestPerformingNewProgress ); this.chosenTickers = new ChosenTickers( this.numberOfTickersToBeChosen ); } private void bestPerformingNewProgress( Object sender , NewProgressEventArgs eventArgs ) { this.InSampleNewProgress( sender , eventArgs ); } #region OneHourAfterMarketCloseEventHandler private void oneHourAfterMarketCloseEventHandler_orderChosenTickers_closePositions( IEndOfDayTimer endOfDayTimer ) { foreach ( Position position in this.account.Portfolio ) if ( this.chosenTickers.Contains( position.Instrument.Key ) ) { this.account.ClosePosition( position ); } } private void oneHourAfterMarketCloseEventHandler_orderChosenTickers_openPositions_forTicker( string ticker ) { double cashForSinglePosition = this.account.CashAmount / this.numberOfTickersToBeChosen; long quantity = Convert.ToInt64( Math.Floor( cashForSinglePosition / this.account.DataStreamer.GetCurrentBid( ticker ) ) ); Order order = new Order( OrderType.MarketBuy , new Instrument( ticker ) , quantity ); this.account.AddOrder( order ); } private void oneHourAfterMarketCloseEventHandler_orderChosenTickers_openPositions() { foreach ( string ticker in this.chosenTickers ) if ( !this.account.Contains( ticker ) ) { oneHourAfterMarketCloseEventHandler_orderChosenTickers_openPositions_forTicker( ticker ); } } private void oneHourAfterMarketCloseEventHandler_orderChosenTickers( IEndOfDayTimer endOfDayTimer ) { this.oneHourAfterMarketCloseEventHandler_orderChosenTickers_closePositions( endOfDayTimer ); this.oneHourAfterMarketCloseEventHandler_orderChosenTickers_openPositions(); } /// <summary> /// Handles a "One hour after market close" event. /// </summary> /// <param name="sender"></param> /// <param name="eventArgs"></param> public void OneHourAfterMarketCloseEventHandler( Object sender , EndOfDayTimingEventArgs endOfDayTimingEventArgs ) { if ( ( this.eligibleTickers.Count == 0 ) || ( endOfDayTimingEventArgs.EndOfDayDateTime.DateTime.CompareTo( this.bestPerformingTickers.LastUpdate.AddDays( this.outOfSampleWindowDays ) ) >= 0 ) ) // either eligible tickers have never been defined yet // or this.outOfSampleWindowDays days elapsed since last best performing tickers calculation { this.eligibleTickers.SetTickers( endOfDayTimingEventArgs.EndOfDayDateTime.DateTime ); this.bestPerformingTickers.SetTickers( this.eligibleTickers , endOfDayTimingEventArgs.EndOfDayDateTime.DateTime ); } this.chosenTickers.SetTickers( this.bestPerformingTickers ); oneHourAfterMarketCloseEventHandler_orderChosenTickers( ( IEndOfDayTimer ) sender ); } #endregion #region FiveMinutesBeforeMarketCloseEventHandler private void fiveMinutesBeforeMarketCloseEventHandler_closePosition( string ticker ) { this.account.ClosePosition( ticker ); } private void fiveMinutesBeforeMarketCloseEventHandler_closePositions() { foreach ( string ticker in this.account.Portfolio.Keys ) fiveMinutesBeforeMarketCloseEventHandler_closePosition( ticker ); } private void fiveMinutesBeforeMarketCloseEventHandler_openPosition( string ticker ) { double maxPositionValue = this.account.CashAmount / this.numberOfTickersToBeChosen; long sharesToBeBought = Convert.ToInt64( Math.Floor( maxPositionValue / this.account.DataStreamer.GetCurrentAsk( ticker ) ) ); this.account.AddOrder( new Order( OrderType.MarketBuy , new Instrument( ticker ) , sharesToBeBought ) ); } private void fiveMinutesBeforeMarketCloseEventHandler_openPositions() { foreach ( string ticker in this.chosenTickers ) this.fiveMinutesBeforeMarketCloseEventHandler_openPosition( ticker ); } public void FiveMinutesBeforeMarketCloseEventHandler( Object sender , EndOfDayTimingEventArgs endOfDayTimingEventArgs ) { this.fiveMinutesBeforeMarketCloseEventHandler_closePositions(); fiveMinutesBeforeMarketCloseEventHandler_openPositions(); } #endregion } } |
|
From: Marco M. <mi...@us...> - 2004-09-05 13:57:13
|
Update of /cvsroot/quantproject/QuantDownloader/Downloader/TickerSelectors In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23882/Downloader/TickerSelectors Modified Files: TickerGroupsViewer.cs Log Message: Changed some messages for the user; cleaned old code Index: TickerGroupsViewer.cs =================================================================== RCS file: /cvsroot/quantproject/QuantDownloader/Downloader/TickerSelectors/TickerGroupsViewer.cs,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** TickerGroupsViewer.cs 4 Aug 2004 23:07:01 -0000 1.5 --- TickerGroupsViewer.cs 5 Sep 2004 13:57:00 -0000 1.6 *************** *** 265,269 **** if(item.Tag is System.String ) // the item contains in Tag property the ticker ID ! Tickers_tickerGroups.Delete((string)item.Tag, (string)this.treeViewGroups.SelectedNode.Tag); else --- 265,269 ---- if(item.Tag is System.String ) // the item contains in Tag property the ticker ID ! QuantProject.DataAccess.Tables.Tickers_tickerGroups.Delete((string)item.Tag, (string)this.treeViewGroups.SelectedNode.Tag); else |
|
From: Marco M. <mi...@us...> - 2004-09-05 13:57:13
|
Update of /cvsroot/quantproject/QuantDownloader/Downloader In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23882/Downloader Modified Files: TickerDownloader.cs WebDownloader.cs Log Message: Changed some messages for the user; cleaned old code Index: WebDownloader.cs =================================================================== RCS file: /cvsroot/quantproject/QuantDownloader/Downloader/WebDownloader.cs,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** WebDownloader.cs 27 Jun 2004 19:21:42 -0000 1.16 --- WebDownloader.cs 5 Sep 2004 13:57:00 -0000 1.17 *************** *** 48,51 **** --- 48,54 ---- private System.Windows.Forms.RadioButton radioButtonDownloadBeforeMinAndAfterMax; private System.Windows.Forms.RadioButton radioButtonDownloadOnlyAfterMax; + private System.Windows.Forms.Button buttonAbort; + private Thread downloadThread = null; + /// <summary> /// Required designer variable. *************** *** 112,115 **** --- 115,119 ---- this.radioButtonDownloadOnlyAfterMax.Checked = true; this.dataGrid1.ContextMenu = new TickerViewerMenu(this); + //this.downloadThread = new Thread( new ThreadStart( this.downloadQuotes_createTickerDataSet)); } *************** *** 144,147 **** --- 148,152 ---- this.radioButtonOverWriteNo = new System.Windows.Forms.RadioButton(); this.radioButtonOverWriteYes = new System.Windows.Forms.RadioButton(); + this.buttonAbort = new System.Windows.Forms.Button(); ((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).BeginInit(); this.groupBoxWebDownloaderOptions.SuspendLayout(); *************** *** 373,376 **** --- 378,391 ---- this.radioButtonOverWriteYes.Text = "Download all quotes, deleting all existing ones in database"; // + // buttonAbort + // + this.buttonAbort.Enabled = false; + this.buttonAbort.Location = new System.Drawing.Point(216, 376); + this.buttonAbort.Name = "buttonAbort"; + this.buttonAbort.TabIndex = 15; + this.buttonAbort.Text = "Abort"; + this.buttonAbort.Visible = false; + this.buttonAbort.Click += new System.EventHandler(this.buttonAbort_Click); + // // WebDownloader // *************** *** 378,381 **** --- 393,397 ---- this.ClientSize = new System.Drawing.Size(840, 470); this.Controls.AddRange(new System.Windows.Forms.Control[] { + this.buttonAbort, this.groupBoxUpdateDatabaseOptions, this.groupBoxWebDownloaderOptions, *************** *** 568,592 **** private void downloadQuotes_withTickerDataSet( DataSet ds ) { ! downloadQuotes_withTickerDataSet_create_dsTickerCurrentlyDownloaded( ds.Tables[0] ); ! foreach (DataRow myRow in ds.Tables[0].Rows) ! { ! //if (this.dsTickerCurrentlyDownloaded.Tables[ "Tickers" ].Rows.Count>5) ! // Monitor.Wait( this.dsTickerCurrentlyDownloaded.Tables[ "Tickers" ] ); ! TickerDownloader qd = new TickerDownloader( this , myRow , myRow["tiTicker"].ToString() , ds.Tables[0].Rows.Count ); ! //Thread newThread = new Thread( new ThreadStart( qd.downloadTicker)); ! //newThread.Start(); ! if(this.radioButtonAllAvailableUntilNowSinceStartingDate.Checked) ! { ! qd.DownloadTicker(this.dateTimePickerStartingDate.Value); ! } ! else { ! qd.DownloadTicker(); } - //newThread.Join(); - //qd.downloadTicker(); - } - //ImportQuotesCsv iqc = new ImportQuotesCsv(); } --- 584,609 ---- private void downloadQuotes_withTickerDataSet( DataSet ds ) { ! ! downloadQuotes_withTickerDataSet_create_dsTickerCurrentlyDownloaded( ds.Tables[0] ); ! foreach (DataRow myRow in ds.Tables[0].Rows) { ! //if (this.dsTickerCurrentlyDownloaded.Tables[ "Tickers" ].Rows.Count>5) ! // Monitor.Wait( this.dsTickerCurrentlyDownloaded.Tables[ "Tickers" ] ); ! TickerDownloader qd = new TickerDownloader( this , myRow , myRow["tiTicker"].ToString() , ds.Tables[0].Rows.Count ); ! //Thread newThread = new Thread( new ThreadStart( qd.downloadTicker)); ! //newThread.Start(); ! if(this.radioButtonAllAvailableUntilNowSinceStartingDate.Checked) ! { ! qd.DownloadTicker(this.dateTimePickerStartingDate.Value); ! } ! else ! { ! qd.DownloadTicker(); ! } ! ! //newThread.Join(); ! //qd.downloadTicker(); } } *************** *** 599,606 **** private void downloadQuotesOfAllTickers() { ! DataSet ds=new DataSet(); ! downloadQuotes_createTickerDataSet( ds ); ! downloadQuotes_withTickerDataSet( ds ); ! this.OleDbConnection1.Close(); } --- 616,636 ---- private void downloadQuotesOfAllTickers() { ! try ! { ! DataSet ds=new DataSet(); ! downloadQuotes_createTickerDataSet( ds ); ! downloadQuotes_withTickerDataSet( ds ); ! this.OleDbConnection1.Close(); ! } ! catch(Exception ex) ! { ! MessageBox.Show(ex.ToString()); ! } ! ! finally ! { ! ! } ! } *************** *** 608,616 **** private void downloadQuotesOfSelectedTickers() { ! DataSet ds=new DataSet(); ! ds.Tables.Add(this.tableOfSelectedTickers); ! downloadQuotes_withTickerDataSet( ds ); ! this.OleDbConnection1.Close(); ! } private void openDbAndSetOleDbCommand() --- 638,660 ---- private void downloadQuotesOfSelectedTickers() { ! try ! { ! DataSet ds=new DataSet(); ! ds.Tables.Add(this.tableOfSelectedTickers); ! downloadQuotes_withTickerDataSet( ds ); ! this.OleDbConnection1.Close(); ! } ! ! catch(Exception ex) ! { ! MessageBox.Show(ex.ToString()); ! } ! ! finally ! { ! ! } ! } ! private void openDbAndSetOleDbCommand() *************** *** 641,659 **** private void button1_Click(object sender, System.EventArgs e) { ! //Cursor.Current = Cursors.WaitCursor; this.openDbAndSetOleDbCommand(); this.downloadQuotesOfAllTickers(); ! this.button1.Enabled = false; ! //Cursor.Current = Cursors.Default; ! } private void buttonDownloadQuotesOfSelectedTickers_Click(object sender, System.EventArgs e) { ! //Cursor.Current = Cursors.WaitCursor; this.openDbAndSetOleDbCommand(); this.downloadQuotesOfSelectedTickers(); ! this.buttonDownloadQuotesOfSelectedTickers.Enabled = false; ! //Cursor.Current = Cursors.Default; } --- 685,706 ---- private void button1_Click(object sender, System.EventArgs e) { ! this.button1.Enabled = false; ! this.buttonAbort.Enabled = true; this.openDbAndSetOleDbCommand(); + //this.downloadThread = new Thread( new ThreadStart(this.downloadQuotesOfAllTickers)); + //this.downloadThread.Start(); this.downloadQuotesOfAllTickers(); ! this.buttonAbort.Enabled = false; } private void buttonDownloadQuotesOfSelectedTickers_Click(object sender, System.EventArgs e) { ! this.buttonDownloadQuotesOfSelectedTickers.Enabled = false; ! this.buttonAbort.Enabled = true; this.openDbAndSetOleDbCommand(); + //this.downloadThread = new Thread( new ThreadStart(this.downloadQuotesOfSelectedTickers)); + //this.downloadThread.Start(); this.downloadQuotesOfSelectedTickers(); ! this.buttonAbort.Enabled = false; } *************** *** 678,681 **** --- 725,734 ---- } + private void buttonAbort_Click(object sender, System.EventArgs e) + { + this.buttonAbort.Enabled = false; + this.downloadThread.Abort(); + } + public bool IsBeforeAndAfterSelected { Index: TickerDownloader.cs =================================================================== RCS file: /cvsroot/quantproject/QuantDownloader/Downloader/TickerDownloader.cs,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** TickerDownloader.cs 4 Aug 2004 23:04:20 -0000 1.12 --- TickerDownloader.cs 5 Sep 2004 13:57:00 -0000 1.13 *************** *** 398,402 **** this.updateCurrentStatusDatabaseUpdated("YES"); else ! this.updateCurrentStatus("NOT FOUND"); } --- 398,402 ---- this.updateCurrentStatusDatabaseUpdated("YES"); else ! this.updateCurrentStatus("Not found updatable quotes"); } *************** *** 407,412 **** this.commitDownloadedValuesToDatabase(); } - - public void DownloadTicker() --- 407,410 ---- *************** *** 449,480 **** // ticker's quotes are downloaded for the first time or // the user has chosen to download all quotes - - /* - - if(this.numberOfQuotesInDatabase>0 && p_myForm.IsUpdateOptionSelected) - // there are some ticker's quotes in the database and - // the user has chosen to download new quotes (only after last quote - // or both before first quote and after last quote) - { - if(this.p_myForm.IsOnlyAfterLastQuoteSelected) - { - this.downloadTickerAfterLastQuote(); - } - else - { - this.downloadTickerBeforeFirstQuote(); - this.downloadTickerAfterLastQuote(); - } - } - else - // ticker's quotes are downloaded for the first time or - // the user has chosen to download all quotes - { - this.resetStartDateIfNecessary(); - setTimeFrameAndImportTickerForEachTimeFrame(200); - } - - */ } --- 447,451 ---- |
|
From: Marco M. <mi...@us...> - 2004-09-05 13:51:52
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22726/b7_Scripts Modified Files: b7_Scripts.csproj Log Message: Added new script file with use of TickerSelectorClass Index: b7_Scripts.csproj =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/b7_Scripts.csproj,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** b7_Scripts.csproj 28 Aug 2004 17:30:30 -0000 1.11 --- b7_Scripts.csproj 5 Sep 2004 13:51:38 -0000 1.12 *************** *** 168,171 **** --- 168,181 ---- /> <File + RelPath = "TickerSelectionTesting\DataStreamerHandler.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File + RelPath = "TickerSelectionTesting\RunBestTwoIndipendent.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File RelPath = "WalkForwardTesting\MSFTwalkForward\RunMSFTwalkForward.cs" SubType = "Code" |
|
From: Marco M. <mi...@us...> - 2004-09-05 13:51:48
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/TickerSelectionTesting In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22726/b7_Scripts/TickerSelectionTesting Added Files: DataStreamerHandler.cs RunBestTwoIndipendent.cs Log Message: Added new script file with use of TickerSelectorClass --- NEW FILE: DataStreamerHandler.cs --- /* QuantProject - Quantitative Finance Library DataStreamerHandler.cs Copyright (C) 2003 Glauco Siliprandi This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License 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; using QuantProject.Business.Financial.Accounting; using QuantProject.Data.DataProviders; using QuantProject.ADT; using QuantProject.Data.Selectors; namespace QuantProject.Scripts.TickerSelectionTesting.BestTwoIndipendent { /// <summary> /// Implements NewQuoteEventHandler. This is the core strategy! /// </summary> public class DataStreamerHandler { private Account account; private ExtendedDateTime openAccountDate; public Account Account { get { return this.account; } } public DataStreamerHandler() { this.account = new Account( "Main" ); this.openAccountDate = new ExtendedDateTime(new DateTime(2002,1,1), BarComponent.Open); this.account.AddCash(this.openAccountDate, 10000); } private DataTable newQuoteEventHandler_getTickersToBuy(Quote encomingQuote) { TickerSelector liquidSelector = new TickerSelector(SelectionType.Liquidity, false, "NSDQ100", this.openAccountDate.DateTime, encomingQuote.ExtendedDataTable.DateTime,50); TickerSelector volatilityCTOselector = new TickerSelector(liquidSelector.GetTableOfSelectedTickers(), SelectionType.CloseToOpenVolatility, true, "", this.openAccountDate.DateTime, encomingQuote.ExtendedDataTable.DateTime, 40); TickerSelector avgCTOperformanceSelector = new TickerSelector(volatilityCTOselector.GetTableOfSelectedTickers(), SelectionType.AverageCloseToOpenPerformance, true, "", this.openAccountDate.DateTime, encomingQuote.ExtendedDataTable.DateTime, 20); TickerSelector correlationSelector = new TickerSelector(avgCTOperformanceSelector.GetTableOfSelectedTickers(), SelectionType.CloseToOpenLinearCorrelation, true, "", this.openAccountDate.DateTime, encomingQuote.ExtendedDataTable.DateTime, 2); return correlationSelector.GetTableOfSelectedTickers(); } public void NewQuoteEventHandler( Object sender , NewQuoteEventArgs eventArgs ) { Quote encomingQuote = eventArgs.Quote; if(this.openAccountDate.DateTime.AddDays(30).CompareTo(encomingQuote.ExtendedDataTable.DateTime)<0) //it has elasped enough time for a significant simulation of the strategy { DataTable tickersToBuy = this.newQuoteEventHandler_getTickersToBuy(encomingQuote); //the script has to be completed ... } } } } --- NEW FILE: RunBestTwoIndipendent.cs --- /* QuantProject - Quantitative Finance Library RunBestTwoIndipendent.cs Copyright (C) 2003 Glauco Siliprandi This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License 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 System.Data; using QuantProject.ADT; using QuantProject.Business.Financial.Accounting.Reporting; using QuantProject.Business.Financial.Instruments; using QuantProject.Business.Scripting; using QuantProject.Business.Strategies; using QuantProject.Business.Testing; using QuantProject.Data.DataTables; using QuantProject.Data.DataProviders; using QuantProject.Presentation.Reporting.WindowsForm; namespace QuantProject.Scripts.TickerSelectionTesting.BestTwoIndipendent { /// <summary> /// Script to test a strategy on many tickers inside a group, /// chosing the best two indipendent tickers /// when a fixed time span has elapsed. /// </summary> public class RunBestTwoIndipendent : Script { private string groupID; private ReportTable reportTable; private ExtendedDateTime startDateTime; private ExtendedDateTime endDateTime; //private int numIntervalDays; private HistoricalDataStreamer historicalDataStreamer; private DataStreamerHandler dataStreamerHandler = new DataStreamerHandler(); public RunBestTwoIndipendent() { this.reportTable = new ReportTable( "Summary_Reports" ); this.startDateTime = new ExtendedDateTime( new DateTime( 2002 , 1 , 1 ) , BarComponent.Open ); this.endDateTime = new ExtendedDateTime( new DateTime( 2002 , 12 , 31 ) , BarComponent.Close ); //this.numIntervalDays = 7; this.groupID = "NSDQ100"; } #region Run private void run_initializeHistoricalDataStreamer_addTickers() { Tickers_tickerGroups tickerInGroupID = new Tickers_tickerGroups(this.groupID); foreach(DataRow row in tickerInGroupID.Rows) { this.historicalDataStreamer.Add((string)row[Tickers_tickerGroups.Ticker]); } } private void run_initializeHistoricalDataStreamer() { this.historicalDataStreamer = new HistoricalDataStreamer(); this.historicalDataStreamer.StartDateTime = this.startDateTime; this.historicalDataStreamer.EndDateTime = this.endDateTime; this.run_initializeHistoricalDataStreamer_addTickers(); } public override void Run() { Report report; run_initializeHistoricalDataStreamer(); this.historicalDataStreamer.NewQuote += new NewQuoteEventHandler( this.dataStreamerHandler.NewQuoteEventHandler ); this.historicalDataStreamer.GoSimulate(); report = new Report( this.dataStreamerHandler.Account ); report.Show(); //???? //report.Show( "Best Two Indipendent" , this.numIntervalDays , this.startDateTime , "MSFT" ); } #endregion } } |