[Quantproject-developers] QuantProject/b3_Data/Selectors SelectorByAbsolutePerformance.cs,NONE,1.1 S
Brought to you by:
glauco_1
Update of /cvsroot/quantproject/QuantProject/b3_Data/Selectors In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4614/b3_Data/Selectors Modified Files: SelectionType.cs TickerSelector.cs Added Files: SelectorByAbsolutePerformance.cs SelectorByAverageCloseToClosePerformance.cs SelectorByAverageOpenToClosePerformance.cs SelectorByCloseToCloseLinearCorrelation.cs SelectorByCloseToCloseVolatility.cs SelectorByLiquidity.cs SelectorByOpenToCloseLinearCorrelation.cs SelectorByOpenToCloseVolatility.cs SelectorByQuotationAtEachMarketDay.cs Log Message: Advanced Ticker selection has been re-organized in a more rational and object-oriented way (NOTE that at the moment Quantdownloader solution won't compile) --- NEW FILE: SelectorByAverageOpenToClosePerformance.cs --- /* QuantProject - Quantitative Finance Library SelectorByAverageOpenToClosePerformance.cs Copyright (C) 2003 Marco Milletti 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 System.Windows.Forms; using QuantProject.DataAccess.Tables; using QuantProject.Data.DataTables; namespace QuantProject.Data.Selectors { /// <summary> /// Class for selection on tickers by average open to close performance /// </summary> public class SelectorByAverageOpenToClosePerformance : TickerSelector, ITickerSelector { public SelectorByAverageOpenToClosePerformance(DataTable setOfTickersToBeSelected, bool orderInASCmode, DateTime firstQuoteDate, DateTime lastQuoteDate, long maxNumOfReturnedTickers): base(setOfTickersToBeSelected, orderInASCmode, firstQuoteDate, lastQuoteDate, maxNumOfReturnedTickers) { } public SelectorByAverageOpenToClosePerformance(string groupID, bool orderInASCmode, DateTime firstQuoteDate, DateTime lastQuoteDate, long maxNumOfReturnedTickers): base(groupID, orderInASCmode, firstQuoteDate, lastQuoteDate, maxNumOfReturnedTickers) { } public DataTable GetTableOfSelectedTickers() { if(this.setOfTickersToBeSelected == null) return QuantProject.DataAccess.Tables.Quotes.GetTickersByAverageCloseToOpenPerformance(this.isOrderedInASCMode, this.groupID, this.firstQuoteDate, this.lastQuoteDate, this.maxNumOfReturnedTickers); else return QuantProject.Data.DataTables.Quotes.GetTickersByAverageCloseToOpenPerformance(this.isOrderedInASCMode, this.setOfTickersToBeSelected, this.firstQuoteDate, this.lastQuoteDate, this.maxNumOfReturnedTickers); } public void SelectAllTickers() { ; } } } --- NEW FILE: SelectorByOpenToCloseLinearCorrelation.cs --- /* QuantProject - Quantitative Finance Library SelectorByOpenToCloseLinearCorrelation.cs Copyright (C) 2003 Marco Milletti 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 System.Windows.Forms; using QuantProject.DataAccess.Tables; using QuantProject.Data.DataTables; namespace QuantProject.Data.Selectors { /// <summary> /// Class for selection on tickers by open to close linear correlation /// </summary> public class SelectorByOpenToCloseLinearCorrelation : TickerSelector, ITickerSelector { public SelectorByOpenToCloseLinearCorrelation(DataTable setOfTickersToBeSelected, bool orderInASCmode, DateTime firstQuoteDate, DateTime lastQuoteDate, long maxNumOfReturnedTickers): base(setOfTickersToBeSelected, orderInASCmode, firstQuoteDate, lastQuoteDate, maxNumOfReturnedTickers) { } public SelectorByOpenToCloseLinearCorrelation(string groupID, bool orderInASCmode, DateTime firstQuoteDate, DateTime lastQuoteDate, long maxNumOfReturnedTickers): base(groupID, orderInASCmode, firstQuoteDate, lastQuoteDate, maxNumOfReturnedTickers) { } public DataTable GetTableOfSelectedTickers() { this.launchExceptionIfGroupIDIsNotEmpty(); return QuantProject.Data.DataTables.Quotes.GetTickersByCloseToOpenPearsonCorrelationCoefficient(this.isOrderedInASCMode, this.setOfTickersToBeSelected, this.firstQuoteDate, this.lastQuoteDate); } private void launchExceptionIfGroupIDIsNotEmpty() { if(this.groupID!="") { throw new Exception("Not implemented: this type of selection works only with few tickers, at the moment"); } } public void SelectAllTickers() { ; } } } --- NEW FILE: SelectorByAverageCloseToClosePerformance.cs --- /* QuantProject - Quantitative Finance Library SelectorByAverageCloseToClosePerformance.cs Copyright (C) 2003 Marco Milletti 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 System.Windows.Forms; using QuantProject.DataAccess.Tables; using QuantProject.Data.DataTables; namespace QuantProject.Data.Selectors { /// <summary> /// Class for selection on tickers by average close to close performance /// </summary> public class SelectorByAverageCloseToClosePerformance : TickerSelector , ITickerSelector { public SelectorByAverageCloseToClosePerformance(DataTable setOfTickersToBeSelected, bool orderInASCmode, DateTime firstQuoteDate, DateTime lastQuoteDate, long maxNumOfReturnedTickers): base(setOfTickersToBeSelected, orderInASCmode, firstQuoteDate, lastQuoteDate, maxNumOfReturnedTickers) { } public SelectorByAverageCloseToClosePerformance(string groupID, bool orderInASCmode, DateTime firstQuoteDate, DateTime lastQuoteDate, long maxNumOfReturnedTickers): base(groupID, orderInASCmode, firstQuoteDate, lastQuoteDate, maxNumOfReturnedTickers) { } public DataTable GetTableOfSelectedTickers() { if(this.setOfTickersToBeSelected == null) return QuantProject.DataAccess.Tables.Quotes.GetTickersByAverageCloseToClosePerformance(this.isOrderedInASCMode, this.groupID, this.firstQuoteDate, this.lastQuoteDate, this.maxNumOfReturnedTickers); else return QuantProject.Data.DataTables.Quotes.GetTickersByAverageCloseToClosePerformance(this.isOrderedInASCMode, this.setOfTickersToBeSelected, this.firstQuoteDate, this.lastQuoteDate, this.maxNumOfReturnedTickers); } public void SelectAllTickers() { ; } } } --- NEW FILE: SelectorByLiquidity.cs --- /* QuantProject - Quantitative Finance Library SelectorByLiquidity.cs Copyright (C) 2003 Marco Milletti 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 System.Windows.Forms; using QuantProject.DataAccess.Tables; using QuantProject.Data.DataTables; namespace QuantProject.Data.Selectors { /// <summary> /// Class for selection on tickers by liquidity /// </summary> public class SelectorByLiquidity : TickerSelector, ITickerSelector { public SelectorByLiquidity(DataTable setOfTickersToBeSelected, bool orderInASCmode, DateTime firstQuoteDate, DateTime lastQuoteDate, long maxNumOfReturnedTickers): base(setOfTickersToBeSelected, orderInASCmode, firstQuoteDate, lastQuoteDate, maxNumOfReturnedTickers) { } public SelectorByLiquidity(string groupID, bool orderInASCmode, DateTime firstQuoteDate, DateTime lastQuoteDate, long maxNumOfReturnedTickers): base(groupID, orderInASCmode, firstQuoteDate, lastQuoteDate, maxNumOfReturnedTickers) { } public DataTable GetTableOfSelectedTickers() { if(this.setOfTickersToBeSelected == null) return QuantProject.DataAccess.Tables.Quotes.GetTickersByLiquidity(this.isOrderedInASCMode, this.groupID, this.firstQuoteDate, this.lastQuoteDate, this.maxNumOfReturnedTickers); else return QuantProject.Data.DataTables.Quotes.GetTickersByLiquidity(this.isOrderedInASCMode, this.setOfTickersToBeSelected, this.firstQuoteDate, this.lastQuoteDate, this.maxNumOfReturnedTickers); } public void SelectAllTickers() { ; } } } --- NEW FILE: SelectorByCloseToCloseVolatility.cs --- /* QuantProject - Quantitative Finance Library SelectorByCloseToCloseVolatility.cs Copyright (C) 2003 Marco Milletti 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 System.Windows.Forms; using QuantProject.DataAccess.Tables; using QuantProject.Data.DataTables; namespace QuantProject.Data.Selectors { /// <summary> /// Class for selection on tickers by close to close volatility /// </summary> public class SelectorByCloseToCloseVolatility : TickerSelector, ITickerSelector { public SelectorByCloseToCloseVolatility(DataTable setOfTickersToBeSelected, bool orderInASCmode, DateTime firstQuoteDate, DateTime lastQuoteDate, long maxNumOfReturnedTickers): base(setOfTickersToBeSelected, orderInASCmode, firstQuoteDate, lastQuoteDate, maxNumOfReturnedTickers) { } public SelectorByCloseToCloseVolatility(string groupID, bool orderInASCmode, DateTime firstQuoteDate, DateTime lastQuoteDate, long maxNumOfReturnedTickers): base(groupID, orderInASCmode, firstQuoteDate, lastQuoteDate, maxNumOfReturnedTickers) { } public DataTable GetTableOfSelectedTickers() { if(this.setOfTickersToBeSelected == null) return QuantProject.DataAccess.Tables.Quotes.GetTickersByCloseToCloseVolatility(this.isOrderedInASCMode, this.groupID, this.firstQuoteDate, this.lastQuoteDate, this.maxNumOfReturnedTickers); else return QuantProject.Data.DataTables.Quotes.GetTickersByCloseToCloseVolatility(this.isOrderedInASCMode, this.setOfTickersToBeSelected, this.firstQuoteDate, this.lastQuoteDate, this.maxNumOfReturnedTickers); } public void SelectAllTickers() { ; } } } --- NEW FILE: SelectorByOpenToCloseVolatility.cs --- /* QuantProject - Quantitative Finance Library SelectorByOpenToCloseVolatility.cs Copyright (C) 2003 Marco Milletti 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 System.Windows.Forms; using QuantProject.DataAccess.Tables; using QuantProject.Data.DataTables; namespace QuantProject.Data.Selectors { /// <summary> /// Class for selection on tickers by open to close volatility /// </summary> public class SelectorByOpenToCloseVolatility : TickerSelector, ITickerSelector { public SelectorByOpenToCloseVolatility(DataTable setOfTickersToBeSelected, bool orderInASCmode, DateTime firstQuoteDate, DateTime lastQuoteDate, long maxNumOfReturnedTickers): base(setOfTickersToBeSelected, orderInASCmode, firstQuoteDate, lastQuoteDate, maxNumOfReturnedTickers) { } public SelectorByOpenToCloseVolatility(string groupID, bool orderInASCmode, DateTime firstQuoteDate, DateTime lastQuoteDate, long maxNumOfReturnedTickers): base(groupID, orderInASCmode, firstQuoteDate, lastQuoteDate, maxNumOfReturnedTickers) { } public DataTable GetTableOfSelectedTickers() { if(this.setOfTickersToBeSelected == null) return QuantProject.DataAccess.Tables.Quotes.GetTickersByCloseToOpenVolatility(this.isOrderedInASCMode, this.groupID, this.firstQuoteDate, this.lastQuoteDate, this.maxNumOfReturnedTickers); else return QuantProject.Data.DataTables.Quotes.GetTickersByCloseToOpenVolatility(this.isOrderedInASCMode, this.setOfTickersToBeSelected, this.firstQuoteDate, this.lastQuoteDate, this.maxNumOfReturnedTickers); } public void SelectAllTickers() { ; } } } --- NEW FILE: SelectorByQuotationAtEachMarketDay.cs --- /* QuantProject - Quantitative Finance Library SelectorByQuotationAtEachMarketDay.cs Copyright (C) 2003 Marco Milletti 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 System.Windows.Forms; using QuantProject.DataAccess.Tables; using QuantProject.Data.DataTables; namespace QuantProject.Data.Selectors { /// <summary> /// Class for selection on tickers quoted at each market day (market index) /// </summary> public class SelectorByQuotationAtEachMarketDay : TickerSelector , ITickerSelector { private string marketIndex; public SelectorByQuotationAtEachMarketDay(DataTable setOfTickersToBeSelected, bool orderInASCmode, DateTime firstQuoteDate, DateTime lastQuoteDate, long maxNumOfReturnedTickers, string marketIndex): base(setOfTickersToBeSelected, orderInASCmode, firstQuoteDate, lastQuoteDate, maxNumOfReturnedTickers) { this.marketIndex = marketIndex; } public SelectorByQuotationAtEachMarketDay(string groupID, bool orderInASCmode, DateTime firstQuoteDate, DateTime lastQuoteDate, long maxNumOfReturnedTickers, string marketIndex): base(groupID, orderInASCmode, firstQuoteDate, lastQuoteDate, maxNumOfReturnedTickers) { this.marketIndex = marketIndex; } public DataTable GetTableOfSelectedTickers() { if(this.marketIndex == "") throw new Exception("You first need to set TickerSelector's property <<MarketIndex>>!"); if(this.setOfTickersToBeSelected == null) return QuantProject.Data.DataTables.TickerDataTable.GetTickersQuotedInEachMarketDay( this.marketIndex, this.groupID, this.firstQuoteDate, this.lastQuoteDate, this.maxNumOfReturnedTickers); else return QuantProject.Data.DataTables.TickerDataTable.GetTickersQuotedInEachMarketDay( this.marketIndex, this.setOfTickersToBeSelected, this.firstQuoteDate, this.lastQuoteDate, this.maxNumOfReturnedTickers); } public void SelectAllTickers() { ; } } } --- NEW FILE: SelectorByAbsolutePerformance.cs --- /* QuantProject - Quantitative Finance Library SelectorByAbsolutePerformance.cs Copyright (C) 2003 Marco Milletti 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 System.Windows.Forms; using QuantProject.DataAccess.Tables; using QuantProject.Data.DataTables; namespace QuantProject.Data.Selectors { /// <summary> /// Class for selection on tickers by liquidity /// </summary> public class SelectorByAbsolutePerformance : TickerSelector, ITickerSelector { public SelectorByAbsolutePerformance(DataTable setOfTickersToBeSelected, bool orderInASCmode, DateTime firstQuoteDate, DateTime lastQuoteDate, long maxNumOfReturnedTickers): base(setOfTickersToBeSelected, orderInASCmode, firstQuoteDate, lastQuoteDate, maxNumOfReturnedTickers) { } public SelectorByAbsolutePerformance(string groupID, bool orderInASCmode, DateTime firstQuoteDate, DateTime lastQuoteDate, long maxNumOfReturnedTickers): base(groupID, orderInASCmode, firstQuoteDate, lastQuoteDate, maxNumOfReturnedTickers) { } public DataTable GetTableOfSelectedTickers() { if(this.setOfTickersToBeSelected == null) return TickerDataTable.GetTickersByPerformance(this.isOrderedInASCMode, this.groupID, this.firstQuoteDate, this.lastQuoteDate, this.maxNumOfReturnedTickers); else return TickerDataTable.GetTickersByPerformance(this.isOrderedInASCMode, this.setOfTickersToBeSelected, this.firstQuoteDate, this.lastQuoteDate, this.maxNumOfReturnedTickers); } public void SelectAllTickers() { ; } } } Index: SelectionType.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b3_Data/Selectors/SelectionType.cs,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** SelectionType.cs 6 Jan 2005 18:40:45 -0000 1.7 --- SelectionType.cs 27 Feb 2005 19:56:07 -0000 1.8 *************** *** 26,30 **** { /// <summary> ! /// Enum for TickerSelector class /// </summary> public enum SelectionType --- 26,31 ---- { /// <summary> ! /// Enum used when selection takes place using visual interfaces ! /// Eeach item stands for a specific object implementing ITickerSelector /// </summary> public enum SelectionType *************** *** 38,42 **** CloseToOpenLinearCorrelation, CloseToCloseLinearCorrelation, ! QuotedInEachMarketDay } } \ No newline at end of file --- 39,43 ---- CloseToOpenLinearCorrelation, CloseToCloseLinearCorrelation, ! QuotedAtEachMarketDay } } \ No newline at end of file Index: TickerSelector.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b3_Data/Selectors/TickerSelector.cs,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** TickerSelector.cs 6 Jan 2005 18:40:45 -0000 1.10 --- TickerSelector.cs 27 Feb 2005 19:56:07 -0000 1.11 *************** *** 31,49 **** { /// <summary> ! /// Class for advanced selections on tickers /// </summary> ! /// <remarks> ! /// Selection depends on the parameters used in the construction of a new TickerSelector object ! /// </remarks> ! public class TickerSelector : ITickerSelector { ! private DataTable setOfTickersToBeSelected = null; ! private SelectionType typeOfSelection; ! private string groupID = ""; ! private string marketIndex = ""; ! private DateTime firstQuoteDate = QuantProject.ADT.ConstantsProvider.InitialDateTimeForDownload; ! private DateTime lastQuoteDate = DateTime.Now; ! private long maxNumOfReturnedTickers = 0; ! private bool isOrderedInASCMode; #region properties --- 31,44 ---- { /// <summary> ! /// Base class for advanced selections on tickers /// </summary> ! public class TickerSelector { ! protected DataTable setOfTickersToBeSelected = null; ! protected string groupID = ""; ! protected DateTime firstQuoteDate = QuantProject.ADT.ConstantsProvider.InitialDateTimeForDownload; ! protected DateTime lastQuoteDate = DateTime.Now; ! protected long maxNumOfReturnedTickers = 0; ! protected bool isOrderedInASCMode; #region properties *************** *** 77,88 **** get{return this.maxNumOfReturnedTickers;} } ! /// <summary> ! /// It gets the type of selection provided by the Ticker Selector ! /// </summary> ! public SelectionType TypeOfSelection ! { ! get{return this.typeOfSelection;} ! } ! /// <summary> /// It gets / sets the order type for the ticker selector --- 72,76 ---- get{return this.maxNumOfReturnedTickers;} } ! /// <summary> /// It gets / sets the order type for the ticker selector *************** *** 93,111 **** set{this.isOrderedInASCMode = value;} } - - /// <summary> - /// It gets / sets the market index for the current ticker selector - /// </summary> - public string MarketIndex - { - get{return this.marketIndex;} - set{this.marketIndex = value;} - } #endregion ! public TickerSelector(DataTable setOfTickersToBeSelected, SelectionType typeOfSelection, bool orderInASCmode, - string groupID, DateTime firstQuoteDate, DateTime lastQuoteDate, --- 81,90 ---- set{this.isOrderedInASCMode = value;} } + #endregion ! public TickerSelector(DataTable setOfTickersToBeSelected, bool orderInASCmode, DateTime firstQuoteDate, DateTime lastQuoteDate, *************** *** 113,324 **** { this.setOfTickersToBeSelected = setOfTickersToBeSelected; ! this.commonInitialization(typeOfSelection, orderInASCmode, groupID, firstQuoteDate,lastQuoteDate,maxNumOfReturnedTickers); } ! public TickerSelector(SelectionType typeOfSelection, bool orderInASCmode, - string groupID, DateTime firstQuoteDate, DateTime lastQuoteDate, long maxNumOfReturnedTickers) { ! this.commonInitialization(typeOfSelection, orderInASCmode, groupID, firstQuoteDate,lastQuoteDate,maxNumOfReturnedTickers); } ! private void commonInitialization(SelectionType typeOfSelection, ! bool orderInASCmode, ! string groupID, DateTime firstQuoteDate, DateTime lastQuoteDate, long maxNumOfReturnedTickers) { - this.typeOfSelection = typeOfSelection; this.isOrderedInASCMode = orderInASCmode; - this.groupID = groupID; this.firstQuoteDate = firstQuoteDate; this.lastQuoteDate = lastQuoteDate; this.maxNumOfReturnedTickers = maxNumOfReturnedTickers; } - - - //implementation of ITickerSelector - public DataTable GetTableOfSelectedTickers() - { - switch (this.typeOfSelection) - { - case SelectionType.Liquidity: - return this.getTickersByLiquidity(); - case SelectionType.Performance: - return this.getTickersByPerformance(); - case SelectionType.CloseToCloseVolatility: - return this.getTickersByCloseToCloseVolatility(); - case SelectionType.CloseToOpenVolatility: - return this.getTickersByCloseToOpenVolatility(); - case SelectionType.AverageCloseToClosePerformance: - return this.getTickersByAverageCloseToClosePerformance(); - case SelectionType.AverageCloseToOpenPerformance: - return this.getTickersByAverageCloseToOpenPerformance(); - case SelectionType.CloseToCloseLinearCorrelation: - return this.getTickersByCloseToCloseLinearCorrelation(); - case SelectionType.CloseToOpenLinearCorrelation: - return this.getTickersByCloseToOpenLinearCorrelation(); - case SelectionType.QuotedInEachMarketDay: - return this.getTickersQuotedInEachMarketDay(); - //this line should never be reached! - default: - return new DataTable(); - } - - } - - private DataTable getTickersByLiquidity() - { - if(this.setOfTickersToBeSelected == null) - return QuantProject.DataAccess.Tables.Quotes.GetTickersByLiquidity(this.isOrderedInASCMode, - this.groupID, - this.firstQuoteDate, - this.lastQuoteDate, - this.maxNumOfReturnedTickers); - - else - return QuantProject.Data.DataTables.Quotes.GetTickersByLiquidity(this.isOrderedInASCMode, - this.setOfTickersToBeSelected, - this.firstQuoteDate, - this.lastQuoteDate, - this.maxNumOfReturnedTickers); - } - - private DataTable getTickersByPerformance() - { - if(this.setOfTickersToBeSelected == null) - return TickerDataTable.GetTickersByPerformance(this.isOrderedInASCMode, - this.groupID, - this.firstQuoteDate, - this.lastQuoteDate, - this.maxNumOfReturnedTickers); - else - return TickerDataTable.GetTickersByPerformance(this.isOrderedInASCMode, - this.setOfTickersToBeSelected, - this.firstQuoteDate, - this.lastQuoteDate, - this.maxNumOfReturnedTickers); - - } - - private DataTable getTickersByAverageCloseToClosePerformance() - { - if(this.setOfTickersToBeSelected == null) - return QuantProject.DataAccess.Tables.Quotes.GetTickersByAverageCloseToClosePerformance(this.isOrderedInASCMode, - this.groupID, this.firstQuoteDate, - this.lastQuoteDate, - this.maxNumOfReturnedTickers); - else - return QuantProject.Data.DataTables.Quotes.GetTickersByAverageCloseToClosePerformance(this.isOrderedInASCMode, - this.setOfTickersToBeSelected, - this.firstQuoteDate, - this.lastQuoteDate, - this.maxNumOfReturnedTickers); - - } - - private DataTable getTickersByAverageCloseToOpenPerformance() - { - if(this.setOfTickersToBeSelected == null) - return QuantProject.DataAccess.Tables.Quotes.GetTickersByAverageCloseToOpenPerformance(this.isOrderedInASCMode, - this.groupID, this.firstQuoteDate, - this.lastQuoteDate, - this.maxNumOfReturnedTickers); - else - return QuantProject.Data.DataTables.Quotes.GetTickersByAverageCloseToOpenPerformance(this.isOrderedInASCMode, - this.setOfTickersToBeSelected, - this.firstQuoteDate, - this.lastQuoteDate, - this.maxNumOfReturnedTickers); - - } - - private DataTable getTickersByCloseToCloseVolatility() - { - if(this.setOfTickersToBeSelected == null) - return QuantProject.DataAccess.Tables.Quotes.GetTickersByCloseToCloseVolatility(this.isOrderedInASCMode, - this.groupID, - this.firstQuoteDate, - this.lastQuoteDate, - this.maxNumOfReturnedTickers); - - else - return QuantProject.Data.DataTables.Quotes.GetTickersByCloseToCloseVolatility(this.isOrderedInASCMode, - this.setOfTickersToBeSelected, - this.firstQuoteDate, - this.lastQuoteDate, - this.maxNumOfReturnedTickers); - } - - private DataTable getTickersByCloseToOpenVolatility() - { - if(this.setOfTickersToBeSelected == null) - return QuantProject.DataAccess.Tables.Quotes.GetTickersByCloseToOpenVolatility(this.isOrderedInASCMode, - this.groupID, - this.firstQuoteDate, - this.lastQuoteDate, - this.maxNumOfReturnedTickers); - - else - return QuantProject.Data.DataTables.Quotes.GetTickersByCloseToOpenVolatility(this.isOrderedInASCMode, - this.setOfTickersToBeSelected, - this.firstQuoteDate, - this.lastQuoteDate, - this.maxNumOfReturnedTickers); - } - - private DataTable getTickersByCloseToCloseLinearCorrelation() - { - this.launchExceptionIfGroupIDIsNotEmpty(); - return QuantProject.Data.DataTables.Quotes.GetTickersByAdjCloseToClosePearsonCorrelationCoefficient(this.isOrderedInASCMode, - this.setOfTickersToBeSelected, - this.firstQuoteDate, - this.lastQuoteDate); - } - - private DataTable getTickersByCloseToOpenLinearCorrelation() - { - - this.launchExceptionIfGroupIDIsNotEmpty(); - - return QuantProject.Data.DataTables.Quotes.GetTickersByCloseToOpenPearsonCorrelationCoefficient(this.isOrderedInASCMode, - this.setOfTickersToBeSelected, - this.firstQuoteDate, - this.lastQuoteDate); - } - - private DataTable getTickersQuotedInEachMarketDay() - { - if(this.marketIndex == "") - throw new Exception("You first need to set TickerSelection's property <<MarketIndex>>!"); - - if(this.setOfTickersToBeSelected == null) - return QuantProject.Data.DataTables.TickerDataTable.GetTickersQuotedInEachMarketDay( - this.marketIndex, this.groupID, this.firstQuoteDate, this.lastQuoteDate, - this.maxNumOfReturnedTickers); - - else - return QuantProject.Data.DataTables.TickerDataTable.GetTickersQuotedInEachMarketDay( - this.marketIndex, this.setOfTickersToBeSelected, this.firstQuoteDate, this.lastQuoteDate, - this.maxNumOfReturnedTickers); - } - - private void launchExceptionIfGroupIDIsNotEmpty() - { - if(this.groupID!="") - { - throw new Exception("Not implemented: this type of selection works only with few tickers, at the moment"); - } - } - - public void SelectAllTickers() - { - ; - } - // end of implementation of ITickerSelector /// <summary> --- 92,120 ---- { this.setOfTickersToBeSelected = setOfTickersToBeSelected; ! this.commonInitialization(orderInASCmode, firstQuoteDate, ! lastQuoteDate, maxNumOfReturnedTickers); } ! public TickerSelector(string groupID, bool orderInASCmode, DateTime firstQuoteDate, DateTime lastQuoteDate, long maxNumOfReturnedTickers) { ! this.groupID = groupID; ! this.commonInitialization(orderInASCmode, firstQuoteDate, ! lastQuoteDate, maxNumOfReturnedTickers); } ! private void commonInitialization(bool orderInASCmode, DateTime firstQuoteDate, DateTime lastQuoteDate, long maxNumOfReturnedTickers) { this.isOrderedInASCMode = orderInASCmode; this.firstQuoteDate = firstQuoteDate; this.lastQuoteDate = lastQuoteDate; this.maxNumOfReturnedTickers = maxNumOfReturnedTickers; } /// <summary> --- NEW FILE: SelectorByCloseToCloseLinearCorrelation.cs --- /* QuantProject - Quantitative Finance Library SelectorByCloseToCloseLinearCorrelation.cs Copyright (C) 2003 Marco Milletti 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 System.Windows.Forms; using QuantProject.DataAccess.Tables; using QuantProject.Data.DataTables; namespace QuantProject.Data.Selectors { /// <summary> /// Class for selection on tickers by close to close linear correlation /// </summary> public class SelectorByCloseToCloseLinearCorrelation : TickerSelector , ITickerSelector { public SelectorByCloseToCloseLinearCorrelation(DataTable setOfTickersToBeSelected, bool orderInASCmode, DateTime firstQuoteDate, DateTime lastQuoteDate, long maxNumOfReturnedTickers): base(setOfTickersToBeSelected, orderInASCmode, firstQuoteDate, lastQuoteDate, maxNumOfReturnedTickers) { } public SelectorByCloseToCloseLinearCorrelation(string groupID, bool orderInASCmode, DateTime firstQuoteDate, DateTime lastQuoteDate, long maxNumOfReturnedTickers): base(groupID, orderInASCmode, firstQuoteDate, lastQuoteDate, maxNumOfReturnedTickers) { } public DataTable GetTableOfSelectedTickers() { this.launchExceptionIfGroupIDIsNotEmpty(); return QuantProject.Data.DataTables.Quotes.GetTickersByAdjCloseToClosePearsonCorrelationCoefficient(this.isOrderedInASCMode, this.setOfTickersToBeSelected, this.firstQuoteDate, this.lastQuoteDate); } private void launchExceptionIfGroupIDIsNotEmpty() { if(this.groupID!="") { throw new Exception("Not implemented: this type of selection works only with few tickers, at the moment"); } } public void SelectAllTickers() { ; } } } |