[Quantproject-developers] QuantProject/b3_Data/Selectors SelectionType.cs,1.2,1.3 TickerSelector.cs,
Brought to you by:
glauco_1
|
From: Marco M. <mi...@us...> - 2004-07-25 12:10:10
|
Update of /cvsroot/quantproject/QuantProject/b3_Data/Selectors In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5067/b3_Data/Selectors Modified Files: SelectionType.cs TickerSelector.cs Log Message: Changed names to the SelectionType enum and updated TickerSelector class Index: SelectionType.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b3_Data/Selectors/SelectionType.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** SelectionType.cs 3 Jul 2004 19:19:56 -0000 1.2 --- SelectionType.cs 25 Jul 2004 12:10:02 -0000 1.3 *************** *** 30,37 **** public enum SelectionType { ! MostLiquid, ! BestPerformer/* ! LessVolatile, ! LessStatisticallyCorrelated*/ } } \ No newline at end of file --- 30,37 ---- public enum SelectionType { ! Liquidity, ! Performance/* ! Volatility, ! StatisticalCorrelation*/ } } \ No newline at end of file Index: TickerSelector.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b3_Data/Selectors/TickerSelector.cs,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** TickerSelector.cs 27 Jun 2004 19:20:31 -0000 1.4 --- TickerSelector.cs 25 Jul 2004 12:10:02 -0000 1.5 *************** *** 33,89 **** /// </summary> /// <remarks> ! /// Filter/selection results depend on the SelectionRule used for the instanciation ! /// of a new TickerSelector /// </remarks> - public class TickerSelector : ITickerSelector { private DataTable setOfTickersToBeSelected = null; ! private SelectionRule selectionRule; ! public TickerSelector(DataTable setOfTickersToBeSelected, SelectionRule selectionRule) { this.setOfTickersToBeSelected = setOfTickersToBeSelected; ! this.selectionRule = selectionRule; } ! public TickerSelector(SelectionRule selectionRule) { ! this.selectionRule = selectionRule; } //implementation of ITickerSelector public DataTable GetTableOfSelectedTickers() { ! if(this.setOfTickersToBeSelected == null && ! this.selectionRule.TypeOfSelection == SelectionType.MostLiquid) ! { ! return QuantProject.DataAccess.Tables.Quotes.GetMostLiquidTickers(this.selectionRule.GroupID, ! this.selectionRule.FirstQuoteDate, ! this.selectionRule.LastQuoteDate, ! this.selectionRule.MaxNumOfReturnedTickers); ! } ! else if(this.setOfTickersToBeSelected != null && ! this.selectionRule.TypeOfSelection == SelectionType.MostLiquid) ! { ! return QuantProject.DataAccess.Tables.Quotes.GetMostLiquidTickers(this.setOfTickersToBeSelected, ! this.selectionRule.FirstQuoteDate, ! this.selectionRule.LastQuoteDate, ! this.selectionRule.MaxNumOfReturnedTickers); ! } ! else if(this.setOfTickersToBeSelected == null && ! this.selectionRule.TypeOfSelection == SelectionType.BestPerformer) ! { ! return TickerDataTable.GetBestPerformingTickers(this.selectionRule.GroupID, ! this.selectionRule.FirstQuoteDate, ! this.selectionRule.LastQuoteDate, ! this.selectionRule.MaxNumOfReturnedTickers); ! } ! else ! return new DataTable(); ! //this line should never be reached!! } public void SelectAllTickers() { --- 33,184 ---- /// </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 DateTime firstQuoteDate = QuantProject.ADT.ConstantsProvider.InitialDateTimeForDownload; ! private DateTime lastQuoteDate = DateTime.Now; ! private long maxNumOfReturnedTickers = 0; ! private bool isOrderedInASCMode; ! #region properties ! /// <summary> ! /// It gets the GroupID from which tickers have to be selected ! /// </summary> ! public string GroupID ! { ! get{return this.groupID;} ! } ! /// <summary> ! /// It gets the first date of selection for the quotes ! /// </summary> ! public DateTime FirstQuoteDate ! { ! get{return this.firstQuoteDate;} ! } ! /// <summary> ! /// It gets the last date of selection for the quotes ! /// </summary> ! public DateTime LastQuoteDate ! { ! get{return this.lastQuoteDate;} ! } ! ! /// <summary> ! /// It gets the max number of tickers to be returned ! /// </summary> ! public long MaxNumOfReturnedTickers ! { ! 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 ! /// </summary> ! public bool IsOrderedInASCMode ! { ! get{return this.isOrderedInASCMode;} ! set{this.isOrderedInASCMode = value;} ! } ! ! #endregion ! ! public TickerSelector(DataTable setOfTickersToBeSelected, SelectionType typeOfSelection, ! bool orderInASCmode, ! string groupID, ! DateTime firstQuoteDate, ! DateTime lastQuoteDate, ! long maxNumOfReturnedTickers) { 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(); ! //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); + + } + public void SelectAllTickers() { *************** *** 96,106 **** /// </summary> /// <param name="dataGrid">The data grid from which the user has selected tickers</param> - - public static DataTable GetTableOfManuallySelectedTickers(DataGrid dataGrid) { DataTable dataTableOfDataGrid = (DataTable)dataGrid.DataSource; ! DataTable tableOfSelectedTickers = new DataTable(); ! TickerDataTable.AddColumnsOfTickerTable(tableOfSelectedTickers); int indexOfRow = 0; while(indexOfRow != dataTableOfDataGrid.Rows.Count) --- 191,198 ---- /// </summary> /// <param name="dataGrid">The data grid from which the user has selected tickers</param> public static DataTable GetTableOfManuallySelectedTickers(DataGrid dataGrid) { DataTable dataTableOfDataGrid = (DataTable)dataGrid.DataSource; ! DataTable tableOfSelectedTickers = dataTableOfDataGrid.Clone(); int indexOfRow = 0; while(indexOfRow != dataTableOfDataGrid.Rows.Count) *************** *** 108,118 **** if(dataGrid.IsSelected(indexOfRow)) { ! DataRow dataRow = tableOfSelectedTickers.NewRow(); ! dataRow[0] = dataTableOfDataGrid.Rows[indexOfRow][0]; ! //dataRow["tiTicker"] = dataTableOfDataGrid.Rows[indexOfRow][0]; ! ! dataRow[1] = dataTableOfDataGrid.Rows[indexOfRow][1]; ! //dataRow["tiCompanyName"] = dataTableOfDataGrid.Rows[indexOfRow][0]; ! tableOfSelectedTickers.Rows.Add(dataRow); } indexOfRow++; --- 200,204 ---- if(dataGrid.IsSelected(indexOfRow)) { ! tableOfSelectedTickers.ImportRow(dataTableOfDataGrid.Rows[indexOfRow]); } indexOfRow++; |