[Quantproject-developers] QuantProject/b3_Data/Selectors SelectionRule.cs,NONE,1.1 SelectionType.cs,
Brought to you by:
glauco_1
|
From: Marco M. <mi...@us...> - 2004-04-25 17:33:08
|
Update of /cvsroot/quantproject/QuantProject/b3_Data/Selectors In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8841/b3_Data/Selectors Added Files: SelectionRule.cs SelectionType.cs TickerSelector.cs Log Message: Added new classes TickerSelector with the subsidiary SelectionRule class, for advanced selection of tickers (types of selections are in the SelectionType enumeration) --- NEW FILE: SelectionRule.cs --- /* QuantProject - Quantitative Finance Library SelectionRule.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.Data; namespace QuantProject.Data.Selectors { /// <summary> /// Selection rule used by the TickerSelector /// </summary> /// <remarks> /// Selection process is based on quotes /// </remarks> public class SelectionRule { private SelectionType typeOfSelection; private string groupID = ""; private DateTime firstQuoteDate = QuantProject.ADT.ConstantsProvider.InitialDateTimeForDownload; private DateTime lastQuoteDate = DateTime.Now; private long maxNumOfReturnedTickers = 0; /// <summary> /// SelectionRule constructor /// </summary> /// <param name="typeOfSelection">Type of selection rule to be applied</param> /// <param name="groupID">GroupID to which ticker to be selected has to belong</param> /// <param name="firstQuoteDate">First date of selection for the quotes</param> /// <param name="lastQuoteDate">Last date of selection for the quotes</param> /// <param name="maxNumOfReturnedTickers">Max number of tickers to be returned</param> public SelectionRule(SelectionType typeOfSelection, string groupID, DateTime firstQuoteDate, DateTime lastQuoteDate, long maxNumOfReturnedTickers) { this.typeOfSelection = typeOfSelection; this.groupID = groupID; this.firstQuoteDate = firstQuoteDate; this.lastQuoteDate = lastQuoteDate; this.maxNumOfReturnedTickers = maxNumOfReturnedTickers; } /// <summary> /// GroupID from which tickers have to be selected /// </summary> public string GroupID { get{return this.groupID;} } /// <summary> /// First date of selection for the quotes /// </summary> public DateTime FirstQuoteDate { get{return this.firstQuoteDate;} } /// <summary> /// Last date of selection for the quotes /// </summary> public DateTime LastQuoteDate { get{return this.lastQuoteDate;} } /// <summary> /// Max number of tickers to be returned /// </summary> public long MaxNumOfReturnedTickers { get{return this.maxNumOfReturnedTickers;} } /// <summary> /// Type of selection provided by the rule /// </summary> public SelectionType TypeOfSelection { get{return this.typeOfSelection;} } } } --- NEW FILE: SelectionType.cs --- /* QuantProject - Quantitative Finance Library SelectionType.cs Copyright (C) 2004 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; namespace QuantProject.Data.Selectors { /// <summary> /// Enum for SelectionRule class /// </summary> public enum SelectionType { MostLiquid/*, LessVolatile, BestPerformer, LessStatisticallyCorrelated*/ } } --- NEW FILE: TickerSelector.cs --- /* QuantProject - Quantitative Finance Library TickerSelector.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.Data; using QuantProject.DataAccess.Tables; using QuantProject.Data.DataTables; namespace QuantProject.Data.Selectors { /// <summary> /// Class for advanced selections on tickers /// </summary> /// <remarks> /// Filter/selection results depend on the SelectionRule used for the instanciation /// of a new TickerSelector /// </remarks> public class TickerSelector : ITickerSelector { private SelectionRule selectionRule; public TickerSelector(SelectionRule selectionRule) { this.selectionRule = selectionRule; } public DataTable GetSelectedTickers() { //TODO: implement switching code to the proper method of selection return Quotes.GetMostLiquidTickers(this.selectionRule.GroupID, this.selectionRule.FirstQuoteDate, this.selectionRule.LastQuoteDate, this.selectionRule.MaxNumOfReturnedTickers); } //implementation of ITickerSelector public TickerDataTable GetTableOfSelectedTickers() { return TickerDataTable.ConvertToTickerDataTable(this.GetSelectedTickers()); } public void SelectAllTickers() { ; } // end of implementation of ITickerSelector } } |